You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by Karan Jain <ka...@gmail.com> on 2011/09/11 09:04:47 UTC

Relative paths for filenames in appender specifications in log4php configuration

Hi All,

 

I have been using log4php for a while now. I just had a query about the
Configurator file -

 

I'm using the XML format for the config file and it looks like -

 

<!-- Test appende to log in loggerTest File-->

    <appender name="testAppender" class="LoggerAppenderRollingFile" >

        <layout class="LoggerLayoutTTCC" />

        <param name="file" value="/var/www/trunk/logs/loggerTest.log" />

        <param name="append" value="true" />

        <param name="maxBackupIndex" value="5" />

        <param name="maxFileSize" value="100KB" />

    </appender>

 

The problem that I'm facing is that when I port the same file to some other
system but to a different directory say /home/testdir instead of /var/www
then it will not be able to find that directory and will not create the log
file.

 

So, is there any way that we can specify relative paths instead of absolute
paths?

 

--

Thanks,

Karan Jain 

 


Re: Relative paths for filenames in appender specifications in log4php configuration

Posted by Ivan Habunek <iv...@gmail.com>.
Hi Karan,

Why don't you just specify a relative path like this:
<param name="file" value="logs/loggerTest.log" />

Providing your PHP working directory is the same as the root of your 
project (where the logs directory is located), it should work as 
expected. You can check with getcwd().

Regards,
Ivan



On 11.9.2011. 9:04, Karan Jain wrote:
> Hi All,
>
> I have been using log4php for a while now. I just had a query about the
> Configurator file –
>
> I’m using the XML format for the config file and it looks like –
>
> <!-- Test appende to log in loggerTest File-->
>
> <appender name="testAppender" class="LoggerAppenderRollingFile" >
>
> <layout class="LoggerLayoutTTCC" />
>
> <param name="file" value="/var/www/trunk/logs/loggerTest.log" />
>
> <param name="append" value="true" />
>
> <param name="maxBackupIndex" value="5" />
>
> <param name="maxFileSize" value="100KB" />
>
> </appender>
>
> The problem that I’m facing is that when I port the same file to some
> other system but to a different directory say /home/testdir instead of
> /var/www then it will not be able to find that directory and will not
> create the log file.
>
> So, is there any way that we can specify relative paths instead of
> absolute paths?
>
> --
>
> Thanks,
>
> Karan Jain
>