How To Change Agent Log Timestamp Format?

Hi,

Right now, our agent timestamps are in the form "HH:MM:SS".  Can that modified to something like "YY/MM/DD-HH:MM:SS"?  That is, can it be modifed to identify the year/month/day (or just month/day) on each entry?  Another possibility would be Julian date+time.  


Thanks,
-T

2 comments
Comment actions Permalink

I figured it out.  The format is changed via the log4j settings. There is a file called “teamcity-agent-log4j.xml” on each agent.  It is specifically  for customization of this type.  I elected for a common fomat, so I changed each occurrence of “%d” to “%d{ISO8601}”.

The previous output looked like this:

[23:23:45]: Updating sources: agent side checkout...
[23:23:45]:      [Updating sources: agent side checkout...] Will perform clean checkout. Reason: Agent doesn't have any version of the project sources
[23:23:45]:      [Updating sources: agent side checkout...] Cleaning D:\work\Staf_2.2\stafTests\..\Tools
           

The new format will be:

[2011-11-06 18:33:52,752]   INFO - ernalArtifactsProcessingLogger - Publishing artifacts process finished

[2011-11-06 18:33:52,767]   INFO -    jetbrains.buildServer.AGENT - Start: Sending files
[2011-11-06 18:33:53,486]   INFO -    jetbrains.buildServer.AGENT - Done publishing artifacts to , total files published: 85

Hope that helps if anyone ever needs it

-T

0
Comment actions Permalink

I tried changing “teamcity-agent-log4j.xml” but this only changes the format of teamcity-agent.log, teamcity-build.log on the agent machine, it does not change the format of time on the teamcity server. Also the default value of %d still prints the datetime in above log files.

[2019-03-11 14:57:17,122] INFO - Starting: C:\BuildAgent2\temp\agentTmp\custom_script7678061715135641806.cmd
[2019-03-11 14:57:17,122] INFO - in directory: C:\BuildAgent2\work\2b35ac7e0452d98f

If I get the same format on the teamcity server which I can download that would be great. It seems like teamcity server is getting each event from the agent and uses its own time or format to log, the logs go in c:\ProgramData\JetBrains\TeamCity\......\[buildnumber]\.teamcity\logs\buildLog.msg5 for each build.

 

 

 

 

0

Please sign in to leave a comment.