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.schoen...@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