TeamCity Plugin Development Help

Plugin Development FAQ

How to Use Logging

The TeamCity code uses the Log4j logging library with a centralized configuration on the server and agent. Logging is usually done via a utility wrapper com.intellij.openapi.diagnostic.Logger rather than the default Log4j classes. You can use the jetbrains.buildServer.log.Loggers class to get instances of the Loggers, e.g. use jetbrains.buildServer.log.Loggers.SERVER to add a message to the teamcity-server.log file.

For plugin-specific logging, it is recommended to log into a log category matching the full name of your class. This is usually achieved by defining the logger field in a class as private static Logger LOG = Logger.getInstance(YourClass.class.getName());.

If your plugin source code is located under the jetbrains.buildServer package, the logging will automatically go into teamcity-server.log.

If you use another package, you might need to add a corresponding category handling into the conf/teamcity-server-log4j.xml file (mentioned at TeamCity Server Logs or the corresponding agent file).

For debugging you might consider creating a customized Log4j configuration file and put it as a logging preset into <TeamCity Data Directory>\config\logging directory. This way one will be able to activate the preset via the Administration | Diagnostics page, Troubleshooting tab.