cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Using log4j under windchill 12

Norbert1
4-Participant

Using log4j under windchill 12

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

1 ACCEPTED SOLUTION

Accepted Solutions

@Norbert1 

Additional advice

Copy my example with all lines and change names of appender and log name as you need.

I has to work 😄

PetrH

View solution in original post

5 REPLIES 5

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

 

HelesicPetr_0-1657890610563.png

 

Norbert1
4-Participant
(To:HelesicPetr)

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

@Norbert1 

Additional advice

Copy my example with all lines and change names of appender and log name as you need.

I has to work 😄

PetrH

Norbert1
4-Participant
(To:HelesicPetr)

Thank you very much - now it works.

Top Tags