Enabling logging for Plastic SCM

Let's talk about how to enable logging in to the Plastic SCM client / server for debugging.

Plastic SCM client logging

The client logging mechanism can be triggered by adding 2 logging configuration files into the plasticscm\client directory. This logs the operations performed by the client GUI plastic.exe or the CLI cm.exe.

For the GUI client plastic.exe, a configuration file for activating the logs called plastic.log.conf should be added in the directory where plastic.exe is. A sample of the configuration file for logging can be downloaded here.

When plastic.exe executes, a log file (txt file) called plastic.log.txt is generated in the same directory as plastic.exe.

For the CLI client cm.exe, the same convention as for plastic.exe is followed, by placing a log activating configuration file called cm.log.conf in the same directory where the cm.exe resides. Operations performed by cm.exe will generate a log file (txt file) called cm.log.txt in that directory. A sample log configuration file can be downloaded here.

When done performing your debugging operations and generating the logs for the client, you should deactivate the logging mechanism so as to not affect the performance in any way. This can be achieved simply by renaming the logging configuration files plastic.log.conf and cm.log.conf. For example, you could call them plastic.log.conf.bck and cm.log.conf.bck.

Plastic SCM server logging

The server already comes with logging activated by means of a logging configuration file called loader.log.conf that can be found in the plasticscm\server directory. When the Plastic SCM server starts, a log file called loader.log.txt is generated in the same directory as the server.

Common for the client / server logging mechanism

  1. To generate new logs, just delete the previously generated ones (.txt) and new log files will be generated upon execution of either plastic.exe or cm.exe.
  2. For the server logs, if you want to generate a new log file, the server must be stopped, delete loader.log.txt, and restart the Plastic server.
  3. Log levels are defined with logging levels from INFO which dumps lightest level of debug information to DEBUG which dumps more debug information. See an example below:
    <level value="DEBUG" />
  4. The DEBUG level in the server to be used ONLY for debugging and extracting some logs in short period of time, and should be relaxed back to its former value while the server is used in production, since it can slightly affect Plastic server performance.
  5. The DEBUG level can be increased or relaxed on the fly by editing the level value parameters.

Further reading

Plastic uses log4net as logging mechanism. It is very flexible when it comes to customizing and logging messages and output. The script below shows how to configure the log (editing loader.log.conf at server's directory) to output errors to the Windows Event Log.

<log4net>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%message%newline" />
        </layout>
    </appender>

    <appender name="FileAppender" type="log4net.Appender.FileAppender">
        <file value="loader.log.txt" />
        <appendToFile value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%message%newline" />
        </layout>
    </appender>

    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
        <threshold value="ERROR" />
        <applicationName value="Plastic Server" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%message%newline" />
        </layout>
    </appender>
    <logger name="UpdatePerf">
        <level value="INFO" />
    </logger>
    <logger name="Transaction">
        <level value="INFO" />
    </logger>
    <logger name="Operations">
        <level value="INFO" />
    </logger>
    <root>
        <level value="ERROR" />
        <appender-ref ref="FileAppender" />
        <appender-ref ref="EventLogAppender" />
    </root>
</log4net>

The sample also shows how to configure Plastic logging to work with selected sources. In this case, we're selecting all the transaction, performance, and operations sources. We normally use the following conversion pattern to define appenders:

<conversionPattern value="%date %property{TransactionID} %property{ClientMachine} %-5level %logger - %message%newline" />

Get the latest news