You can enable trace before an application starts.



To enable trace before an application starts, you can set the following environment variables:

  • On Windows: set MQLIGHT_JAVA_LOG=all
  • On Linux and Mac OS: export MQLIGHT_JAVA_LOG=all

You must first find the process ID for the application and complete the following the steps.



The examples provided start with a logging level of all. The following levels of trace are also available:

  • off – all logging is turned off.
  • error – log error events only.
  • warning – additionally log warning events.
  • info – additionally log informational events.
  • debug – additionally log debugging information events.
  • trace – additionally log trace events, which includes method entry, exit, exception throwing, and data events.
  • all – log everything (which can quickly output a high volume of data).

 
The Java client logs using the SLF4J interfaces. If the client is used in a run time where an implementation of SLF4J is already started, this implementation is used for logging. If the client is used in a run time where logback is used to implement SLF4J and the LogManager has not been started, the client configures logback itself. Currently this configuration involves enabling WARN and higher logging unless the MQLIGHT_JAVA_LOG environment variable is set. If MQLIGHT_JAVA_LOG is set, the level the variable specifies is enabled using logback’s BasicConfigurator.
 

You can also set some other environment variables as follows to control the logging behavior when MQLIGHT_JAVA_LOG is set:

  • Set the MQLIGHT_JAVA_LOG_STREAM environment variable to specify the log output.
    By default, log output up to and including the debug level goes to STDOUT and trace level and higher goes to STDERR. You can set MQLIGHT_JAVA_LOG_STREAM to a file path prefix to direct log output to log files that are named in the following format:
    {file path prefix}%i.log for log output up to and including the debug level.
    {file path prefix}%i.trc for log output of the trace level.
    where %i is blank for the current log file and an index number that starts at 1 for archive log files.
     
    A logback RollingFileAppender with a FixedWindowRollingPolicy and SizeBasedTriggeringPolicy is used to ensure the current log file does not exceed a certain size (the default size is 20 MB) and is rolled over to an archive file to start a fresh log file. By default, up to 5 archived log files are kept and the oldest is deleted when required to make room for a new archive file.
     
    You can also set MQLIGHT_JAVA_LOG_STREAM to STDOUT or STDERR so that all log output goes to STDOUT or STDERR as required.
     

  • Set the MQLIGHT_JAVA_LOG_FILE_COUNT environment variable to specify the number of archive log files that are kept when MQLIGHT_JAVA_LOG_STREAM is specified as a file path prefix.
  • Set the MQLIGHT_JAVA_LOG_FILE_LIMIT environment variable to specify the maximum size of the log files when MQLIGHT_JAVA_LOG_STREAM is specified as a file path prefix. You can specify the value in bytes, kilobytes, megabytes, or gigabytes by suffixing a numeric value with B, KB, MB, or GB.
  • Set the MQLIGHT_JAVA_LOG_TRACE_ARG_MAX_BYTES environment variable to specify the maximum number of bytes output for each argument and to truncate any arguments that are over the length limit from the right. By default, the maximum number of bytes output for each argument is 1024.

Join The Discussion

Your email address will not be published.