Flynsarmy / Slim-Monolog

Monolog logging support for Slim Framework
114 stars 17 forks source link

log directory path concatenation is wrong #10

Open elburro1887 opened 9 years ago

elburro1887 commented 9 years ago

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.

Flynsarmy commented 9 years ago

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

elburro1887 commented 9 years ago

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

Flynsarmy commented 9 years ago

PRs are welcome.

elburro1887 commented 9 years ago

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

OlivierBerro commented 9 years ago

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.

fearlex commented 9 years ago

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

JoshWillik commented 8 years ago

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