[prev in list] [next in list] [prev in thread] [next in thread]
List: log4cxx-user
Subject: Re: Concurrent access
From: drkmkzs <drkmkzs () gmail ! com>
Date: 2012-02-23 12:02:06
Message-ID: CAM_s89n3anw5xUPm8joae8Hiwt2CuQY-n0PHzq5QYeULRmq+sg () mail ! gmail ! com
[Download RAW message or body]
Hey !
This is a really helpfull answer, that's exactly what I wanted, because
like you I don't really like to put log configuration within the code :)
I'm looking forward to use it ;)
I'll try later to determine Log4cxx behaviour with 2 applic, just to know,
it's still an intersting question...
Thanks a lot Thorsten !
2012/2/23 Thorsten Schöning <tschoening@am-soft.de>
> Guten Tag drkmkzs,
> am Mittwoch, 22. Februar 2012 um 16:55 schrieben Sie:
>
> > And i imagine a better approach would be to configure log4cxx within the
> > code (instead property file) in order to change log file name for each
> > processess ?
>
> Not necessarily. I don't know if log4cxx properly handles concurrent
> access to the same file on a per process basis, but I personally
> dislike configuring log4cxx in code and in your case it wouldn't be
> necessary, depending on what your really try to achieve with your log
> files. If it's just about to separate the log files of more than one
> instance of your program, one approach could be to provide a unique
> environment variable in your program on per instance basis before
> configuring log4cxx with its property or xml file, because log4cxx is
> able to use environment variable in the configuration at least in
> paths. I use that to distinct two calls of the same program by
> different callers where the callers provide an id of who they are and
> that id is set as an environment variable and used in the log
> configuration as part of the path to the log file. This ID can be
> whatever you like, process id, GUID, something from the caller, it all
> depends on what you do with the logs.
>
> The syntax to get something from the environment is ${something}, like
> in the following example:
>
> <appender name="Dbxml.monthSpecificLogFile"
> class="org.apache.log4j.rolling.RollingFileAppender">
> <rollingPolicy
> class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
> <param name="FileNamePattern"
>
> value="..\..\..\Datenserver\Logdateien\dbxml\dbxml\${mandant}\%d{yyyy-MM}.log"
> />
> </rollingPolicy>
> <layout class="org.apache.log4j.PatternLayout">
> <param name="ConversionPattern"
> value="%d{yyyy-MM-dd HH:mm:ss,SSS} %p> %c.%M: %m%n"
> />
> </layout>
> <param name="append"
> value="true"
> />
> </appender>
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning E-Mail:Thorsten.Schoening@AM-SoFT.de
> AM-SoFT IT-Systeme http://www.AM-SoFT.de/
>
> Telefon.............030-2 1001-310
> Fax...............05151- 9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hanover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>
[Attachment #3 (text/html)]
<div>Hey ! </div><div><br></div><div>This is a really helpfull answer, that's \
exactly what I wanted, because like you I don't really like to put log \
configuration within the code :) </div><div><br></div><div>I'm looking forward \
to use it ;) </div> <div>I'll try later to determine Log4cxx behaviour with 2 \
applic, just to know, it's still an intersting \
question...</div><div><br></div><div>Thanks a lot Thorsten !</div><br><div \
class="gmail_quote">2012/2/23 Thorsten Schöning <span dir="ltr"><<a \
href="mailto:tschoening@am-soft.de">tschoening@am-soft.de</a>></span><br> \
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Guten Tag drkmkzs,<br> am Mittwoch, 22. Februar 2012 um 16:55 \
schrieben Sie:<br> <div class="im"><br>
> And i imagine a better approach would be to configure log4cxx within the<br>
> code (instead property file) in order to change log file name for each<br>
> processess ?<br>
<br>
</div>Not necessarily. I don't know if log4cxx properly handles concurrent<br>
access to the same file on a per process basis, but I personally<br>
dislike configuring log4cxx in code and in your case it wouldn't be<br>
necessary, depending on what your really try to achieve with your log<br>
files. If it's just about to separate the log files of more than one<br>
instance of your program, one approach could be to provide a unique<br>
environment variable in your program on per instance basis before<br>
configuring log4cxx with its property or xml file, because log4cxx is<br>
able to use environment variable in the configuration at least in<br>
paths. I use that to distinct two calls of the same program by<br>
different callers where the callers provide an id of who they are and<br>
that id is set as an environment variable and used in the log<br>
configuration as part of the path to the log file. This ID can be<br>
whatever you like, process id, GUID, something from the caller, it all<br>
depends on what you do with the logs.<br>
<br>
The syntax to get something from the environment is ${something}, like<br>
in the following example:<br>
<br>
<appender name="Dbxml.monthSpecificLogFile"<br>
class="org.apache.log4j.rolling.RollingFileAppender"><br>
<rollingPolicy \
class="org.apache.log4j.rolling.TimeBasedRollingPolicy"><br> <param \
name="FileNamePattern"<br>
\
value="..\..\..\Datenserver\Logdateien\dbxml\dbxml\${mandant}\%d{yyyy-MM}.log"<br>
/><br>
</rollingPolicy><br>
<layout class="org.apache.log4j.PatternLayout"><br>
<param name="ConversionPattern"<br>
value="%d{yyyy-MM-dd HH:mm:ss,SSS} %p> %c.%M: \
%m%n"<br> /><br>
</layout><br>
<param name="append"<br>
value="true"<br>
/><br>
</appender><br>
<br>
Mit freundlichen Grüßen,<br>
<br>
Thorsten Schöning<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Thorsten Schöning E-Mail:Thorsten.Schoening@AM-SoFT.de<br>
AM-SoFT IT-Systeme <a href="http://www.AM-SoFT.de/" \
target="_blank">http://www.AM-SoFT.de/</a><br> <br>
Telefon.............030-2 1001-310<br>
Fax...............05151- 9468- 88<br>
Mobil..............0178-8 9468- 04<br>
<br>
AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln<br>
AG Hanover HRB 207 694 - Geschäftsführer: Andreas Muchow<br>
<br>
</font></span></blockquote></div><br>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic