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 two 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:
    1. Add the configuration file plastic.log.conf in the directory where plastic.exe is located. You can download a sample of the configuration file for logging here .
    2. Edit the plastic.log.conf file and customize the output file value:
      • If you are on Linux:

        from

        <file value="plastic" />
        

        to

        <file value="${HOME}/.plastic4/plastic.log.txt" />
        
      • If you are on Windows:

        from

        <file value="plastic" />
        

        to

        <file value="${LOCALAPPDATA}\plastic4\logs\plastic.log.txt" />
        
    3. When plastic.exe executes, the log file plastic.log.txt is generated in the specified path.
  • For the CLI client cm.exe:
    1. Add the configuration file cm.log.conf in the directory where the cm.exe resides. You can download a sample of the configuration file for logging here .
    2. Edit the cm.log.conf file and customize the output file value:
      • If you are on Linux:

        from

        <file value="cm.log.txt" />
        

        to

        <file value="${HOME}/.plastic4/cm.log.txt" />
        
      • If you are on Windows:

        from

        <file value="cm.log.txt" />
        

        to

        <file value="${LOCALAPPDATA}\plastic4\logs\cm.log.txt" />
        
    3. The operations performed by cm.exe will generate the log file cm.log.txt in the specified directory.

    Note: If you need to log more than one cm processes, you must add the type="log4net.Util.PatternString" pair to the file key:


    <file type="log4net.Util.PatternString" value="${LOCALAPPDATA}\plastic4\logs\cm-%processid.log.txt" />
    

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

  • 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.
  • 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.
  • 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" />
  • 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.
  • 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" />