Forward build logs to log aggregator

I believe this question's been asked before. However, I couldn't find any definitive answers or solutions.
We want to be able to log to Graylog, for example.
Has anyone been able to do this successfully?

Thanks.

0
8 comments

Hi! The log aggregator solution should include a way to ship the log files from a remote host. You can use such a shipper to ship the files from the TeamCity log locations. This is what those locations are:

  1. TeamCity server logs: <TeamCity_home_directory>/logs
  2. TeamCity agent logs: <Agent_home_directory>/logs
  3. Build logs are stored in binary format in the artifact_storage. If you need those, you will need to obtain the plain text versions of those via HTTP: http://{TEAMCITY_SERVERNAME}/downloadBuildLog.html?buildId={ID_OF_A_BUILD}

I hope that helps.

0

Thanks for the detailed info, Anatoly Cherenkov.
However, I was thinking of a more "built-in" solution.
Something on the server or agent side, whichever makes more sense. That would forward the logs to Graylog.
Something like a plugin that hooks up into the logging "internals". Is that possible, or am I talking complete nonsense?

Thanks.

0
Currently, there is no such feature available out of the box. There is a request for it in our tracker though: https://youtrack.jetbrains.com/issue/TW-70897. Please, feel free to upvote it.
0

Thank you Anatoly Cherenkov,
I understand that such a feature isn't available out of the box. And was hoping to get more information on developing such a feature. A plugin, for example. According to the JetBrains docs here, it looks like there are interfaces and methods that would allow us to do that. I am not a developer, so I could be misinterpreting this entirely.

Thanks.

0

Further development is probably not required, but you'll need to configure a log4j preset and appenders yourself. 
In the TC_DATA_DIR/config/_logging you can find logging presets, please feel free to add your ones here as well. More information here: https://www.jetbrains.com/help/teamcity/teamcity-server-logs.html#General+Logging+Configuration

Also, I would recommend you to wrap your appenders with "DelegateAppender", because it will provide TC features such as masking out passwords.

You can either go with jsonLayout which is available out of the box + SocketAppender or SyslogAppender, or add your own ones, but in this case you'll need to develop a plugin

0

Thank you Sergey Pak,
This is what I had in mind. So, in this case, it looks like I should be able to use the below appender?
https://central.sonatype.dev/artifact/org.graylog2/gelfj/1.1.16
So that I can log in the correct format for Graylog to pick up.
Basically, what I'm trying to understand is how this was done.


Thanks.

0

Nikola Balinski, if you appender requires extra libraries, it would be a bit more difficult and will require maintenance. The thing is that you need to add this library to the app package so TeamCity's logging module will be able to find it.

The simplest way is probably to add them to the TeamCity/webapps/ROOT/WEB-INF/lib. However, this directory will be overriden during the upgrade, so you need to maintain these extra libs yourself.

Concerning the post you've mentioned. It's about log4j v1, which was a bit trickier to customize. Currently, TC utilizes log4j2, which should be able to handle custom appenders and layouts.

0

Thanks, Sergey Pak,
I will look into your suggestions further.

0

Please sign in to leave a comment.