Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hi all,
I want to define a custom log file in Windchill 12, where I want to log messages into instead of into MethodServerLog-file.
The message-level should be given as INFO.
I tried the following changes in log4jMethodServer.properties:
...
appender.zfLogFile.type = RollingFile
appender.zfLogFile.name = zfLogFile
appender.zfLogFile.createOnDemand = true
appender.zfLogFile.fileName = ${sys:wt.logs.dir}/zf/zf-${sys:wt.jvm.startTime.formatted.short}-${sys:wt.jvm.id}-log4j.log
appender.zfLogFile.filePattern = ${sys:wt.logs.dir}/zf/zf-${sys:wt.jvm.startTime.formatted.short}-${sys:wt.jvm.id}-log4j.log.%d{yyyy-MM-dd}_%i
appender.zfLogFile.layout.type = PatternLayout
appender.zfLogFile.layout.alwaysWriteExceptions = false
appender.zfLogFile.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS}{${timeZone}} %-5p [%t] %c %X{user} - %m%ex%n
logger.extLogger.name=zfLogFile
logger.extLogger.level=INFO
logger.extLogger.additivity=false
...
But this doesn't work, the file under ...\logs\zf\<filename> is not created.
Only log.error(...) messages are logged in the MethodServerLog-File.
Thanks for any hint.
Regards
Norbert
Solved! Go to Solution.
Additional advice
Copy my example with all lines and change names of appender and log name as you need.
I has to work 😄
PetrH
Hi @Norbert1
You need to define reference for logger to appender.
logger.IntegrationAV.appenderRef.IntegrationAVAppender.ref=IntegrationAVAppender
Here is example which works:
logger.IntegrationAV.name=cz.aveng.IntegrationAV
logger.IntegrationAV.level=TRACE
logger.IntegrationAV.appenderRef.IntegrationAVAppender.ref=IntegrationAVAppender
appender.IntegrationAVAppender.type = RollingFile
appender.IntegrationAVAppender.name = IntegrationAVAppender
appender.IntegrationAVAppender.fileName = ${sys:wt.logs.dir}/IntegrationAV-${sys:wt.jvm.startTime.formatted.short}-${sys:wt.jvm.id}-log4j.log
appender.IntegrationAVAppender.filePattern = ${sys:wt.logs.dir}/IntegrationAV-${sys:wt.jvm.startTime.formatted.short}-${sys:wt.jvm.id}-log4j.log.%d{yyyy-MM-dd}_%i
appender.IntegrationAVAppender.layout.type = PatternLayout
appender.IntegrationAVAppender.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS}{${timeZone}} %-5p [%t] %c - %m%ex%n
appender.IntegrationAVAppender.policies.type = Policies
appender.IntegrationAVAppender.policies.midnight.type = SizeBasedMidnightTriggeringPolicy
appender.IntegrationAVAppender.policies.midnight.size=9MB
appender.IntegrationAVAppender.strategy.type = DefaultRolloverStrategy
appender.IntegrationAVAppender.strategy.max = 2147483647
Hi Petr,
thanks for your answer.
I tried it in my environment, see my entries in log4jMethodServer.properties:
...
appender.zfLogFile.type = RollingFile
appender.zfLogFile.name = zfLogFile
appender.zfLogFile.createOnDemand = true
appender.zfLogFile.fileName = ${sys:wt.logs.dir}/zf/zf-${sys:wt.jvm.startTime.formatted.short}-${sys:wt.jvm.id}-log4j.log
appender.zfLogFile.filePattern = ${sys:wt.logs.dir}/zf/zf-${sys:wt.jvm.startTime.formatted.short}-${sys:wt.jvm.id}-log4j.log.%d{yyyy-MM-dd}_%i
appender.zfLogFile.layout.type = PatternLayout
appender.zfLogFile.layout.alwaysWriteExceptions = false
appender.zfLogFile.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS}{${timeZone}} %-5p [%t] %c %X{user} - %m%ex%n
logger.ext.level=INFO
logger.ext.name=ext
logger.ext.additivity=true
logger.ext.appenderRef.zfLogFile.ref=zfLogFile
...
--> but it doesn't work, the custom log-file is not created !
Do you see anything wrong in my configuration?
Any hint would be helpful.
Thank you.
Norbert
Hi @Norbert1
I had trouble that all parameters were not set. So Try to set all lines as I showed in my example.
for example I had to add following (I can not see it in your example)
appender.IntegrationAVAppender.policies.type = Policies
appender.IntegrationAVAppender.policies.midnight.type = SizeBasedMidnightTriggeringPolicy
appender.IntegrationAVAppender.policies.midnight.size=9MB
appender.IntegrationAVAppender.strategy.type = DefaultRolloverStrategy
appender.IntegrationAVAppender.strategy.max = 2147483647
also remove a line CreateOnDemand=true
PetrH
Additional advice
Copy my example with all lines and change names of appender and log name as you need.
I has to work 😄
PetrH
Thank you very much - now it works.