You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Dirk Ulrich <Di...@gmx.de> on 2006/02/01 10:05:37 UTC

Defining the path for my logfiles

Hello.

The sources of my current development dir is D:\projects\SPI\java\src and I
am using log4j to log the app's messages. In the log4.properites file I have
defined several Appenders and I wonder why the following happens:

log4j.appender.SPEventAppender.file=\logs\SPEventLogfile.log  --> results in
storing the logfiles in D:\projects\SPI\java\src\SPEventLogfile.log

log4j.appender.SPAppender.file=/logs/SPLogfile.log --> results in storing
the logifles in D:\logs\SPLogfile.log

log4j.appender.DMAspectAppender.file=\logs\DMAspectLogfile.log --> results
in storing the logfiles in D:\projects\SPI\java\src\DMAspectLogfile.log

log4j.appender.DMAppender.file=logs\DMLogfile.log --> results in storing the
logfiles in D:\projects\SPI\java\src\DMLogfile.log

Is it possible to provide a path for my RollingfileAppender's logfiles
relative to my application's install dir? For instance related to my app's
directory: D:\projects\SPI\java\src I want to store the logfiles in
D:\projects\SPI\java\src\logs\*.log (or anywhere else) using relative paths
rather than absolute paths.

Thank you,
Dirk

-- 
DSL-Aktion wegen gro�er Nachfrage bis 28.2.2006 verl�ngert:
GMX DSL-Flatrate 1 Jahr kostenlos* http://www.gmx.net/de/go/dsl

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Defining the path for my logfiles

Posted by Jacob Kjome <ho...@visi.com>.
Quoting Dirk Ulrich <Di...@gmx.de>:

> Hello.
>
> The sources of my current development dir is D:\projects\SPI\java\src and I
> am using log4j to log the app's messages. In the log4.properites file I have
> defined several Appenders and I wonder why the following happens:
>
> log4j.appender.SPEventAppender.file=\logs\SPEventLogfile.log  --> results in
> storing the logfiles in D:\projects\SPI\java\src\SPEventLogfile.log
>

I'm not sure about the specific issue, but if you define backlashes in your
path, you need to escape them.  For instance, the following are equivalent...

\\logs\\mylog.log
/logs/mylog.log

Both will give you a path based off the root of the filesystem.  On windows, it
would be whatever drive that the java command was run from.  Now, if you want a
relative path, you could define it as...

.\\logs\\mylog.log
./logs/mylog.log

Both of these will be relative to the directory where the java command was run.

It would behoove you to use the single forward slashes rather than the double
backslshes since the backslashes tie you to windows.  Forward slashes will work
on both Windows and Unix.

More below...

> log4j.appender.SPAppender.file=/logs/SPLogfile.log --> results in storing
> the logifles in D:\logs\SPLogfile.log
>
> log4j.appender.DMAspectAppender.file=\logs\DMAspectLogfile.log --> results
> in storing the logfiles in D:\projects\SPI\java\src\DMAspectLogfile.log
>
> log4j.appender.DMAppender.file=logs\DMLogfile.log --> results in storing the
> logfiles in D:\projects\SPI\java\src\DMLogfile.log
>
> Is it possible to provide a path for my RollingfileAppender's logfiles
> relative to my application's install dir? For instance related to my app's
> directory: D:\projects\SPI\java\src I want to store the logfiles in
> D:\projects\SPI\java\src\logs\*.log (or anywhere else) using relative paths
> rather than absolute paths.
>

Yes, run your java command from the install dir.  All relative paths, such as
"./logs/mylog.log" will be relative to that directory.

Jake

> Thank you,
> Dirk
>
> --
> DSL-Aktion wegen großer Nachfrage bis 28.2.2006 verlängert:
> GMX DSL-Flatrate 1 Jahr kostenlos* http://www.gmx.net/de/go/dsl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org