I know it's not exactly what you are looking for, but perhaps you can adapt a method that we use in our projects. We have many instances running of the same program, and for historical purposes, always named log files with the Process ID in them to keep them separate. To do this in log4cxx, before initializing, I add an environment variable:
#ifdef _MSC_VER long processId = _getpid(); char logpid[20]; sprintf_s(logpid, "LOGPID=%ld", processId); _putenv(logpid); #else long processId = getpid(); char logpid[20]; sprintf(logpid, "LOGPID=%ld", processId); putenv(logpid); #endif //_MSC_VER Then in my configuration file I do: <appender name="RFA" class="org.apache.log4j.rolling.RollingFileAppender"> <rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy"> <param name="activeFileName" value="MyApp_${LOGPID}.log"/> <param name="fileNamePattern" value="MyApp_${LOGPID}.log.%i"/> <param name="minIndex" value="0"/> <param name="maxIndex" value="5"/> </rollingPolicy> <triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy"> <param name="MaxFileSize" value="30MB"/> </triggeringPolicy> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{MM/dd HH:mm:ss.SSS} %c - %m%n"/> </layout> <param name="file" value="MyApp_${LOGPID}.log"/> <param name="append" value="false"/> </appender> I'm not sure who handles it (log4cxx or the system), but somehow the variable gets properly substituted. Hope this helps. -Andy You wrote: Hi Anand, thanks for your reply. But I think it should be a normal function for a logging library to create logfiles for each start of an application. The renaming was only an example. Of course it would also be okay using the rollOver Function of log4cxx. But logging seems either size or time related. Hm, if there's no alternative I've got to do it my own. Best regards, Alex Hi Alex, Did you find solution to your problem? Can you please share it? Regards, Anand.