Slim-Monolog icon indicating copy to clipboard operation
Slim-Monolog copied to clipboard

log directory path concatenation is wrong

Open elburro1887 opened this issue 10 years ago • 7 comments

The newest commit for monolog 1.15.0 breaks my logging:

$config['app']['log.writer'] = new \Flynsarmy\SlimMonolog\Log\MonologWriter(array(
    'handlers' => array(
        new \Monolog\Handler\StreamHandler(
            realpath(__DIR__ . '/logs')
                .'/'.$_ENV['SLIM_MODE'] . '_' .date('Y-m-d').'.log'
        ),
    ),
));

I get this error:

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'There is no existing directory at "./logs" and its not buildable: Permission denied'

When I output the $stream in StreamHandler->construct() i get:

mylocalhost/mysite/logs/development_2015-07-17.log./logs/15-07-17.log

It seems like the path concatenation is somehow off.

elburro1887 avatar Jul 17 '15 05:07 elburro1887

Was this not fixed in release 1.0.1? See PR #9

Flynsarmy avatar Jul 17 '15 05:07 Flynsarmy

I just pulled the latest from composer, seems to be still an issue

elburro1887 avatar Jul 17 '15 05:07 elburro1887

PRs are welcome.

Flynsarmy avatar Jul 17 '15 05:07 Flynsarmy

ok just did some more testing. If i run monolog 1.14.0 with slim-monolog 1.0.1 it works. but 1.15.0 with 1.0.1 does not work

elburro1887 avatar Jul 17 '15 05:07 elburro1887

The problem is that there is a

new \Monolog\Handler\StreamHandler('./logs/'.date('y-m-d').'.log')

in the constructor which throws an exception if there is no "./logs/" folder in your project.

To get around this you should define all parameters (name, handlers, processors) and pass false as second argument to the MonologWriter.

OlivierBerro avatar Jul 22 '15 11:07 OlivierBerro

I was able to resolve this issue by setting permissions to 777 for my custom log folder. Just adding my 2 cents.

fearlex avatar Oct 03 '15 07:10 fearlex

The default constructor option mentioned by @OlivierBerro disappeared in #13.

JoshWillik avatar Mar 19 '16 21:03 JoshWillik