Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO

Can I write debug-level logging in a separate file?

0 votes
108 views
asked Nov 30, 2016 in CompleteFTP by EDT Support (41,570 points)

A user asked us:

would you happen to have a sample log config that sends debug messages to another log file

 

1 Answer

0 votes
answered Nov 30, 2016 by EDT Support (41,570 points)
 
Best answer
Yes, the following logging configuration will write two log-files: one  (Summary.log) containing only log message of level INFO and lower, and the other (Verbose.log) containing all log messages being logged by CompleteFTP regardless of the level .  Keep in mind that CompleteFTP has its own internal log level, so if that's set to INFO or lower then Summary.log will be identical.

The following logging configuration should be saved in a file called LogConfig.xml and saved in C:\ProgramData\Enterprise Distributed Technologies\Complete FTP\Logs:

<?xml version="1.0" encoding="UTF-8"?>
<log4net>
    <!-- This appended logs to audit file -->
    <appender name="Audit" type="log4net.Appender.RollingFileAppender">
        <filter type="log4net.Filter.LoggerMatchFilter">
            <loggerToMatch value="Audit" />
            <acceptOnMatch value="true" />
        </filter>
        <filter type="log4net.Filter.LoggerMatchFilter">
            <loggerToMatch value="ConfigLog" />
            <acceptOnMatch value="false" />
        </filter>
        <filter type="log4net.Filter.DenyAllFilter" />
        <file type="log4net.Util.PatternString">
            <converter>
                <name value="folder" />
                <type value="EnterpriseDT.Util.Debug.SpecialFolderPatternConverter" />
            </converter>
            <conversionPattern value="%folder{CommonApplicationData}\Enterprise Distributed Technologies\Complete FTP\logs\Audit.log" />
        </file>
        <param name="AppendToFile" value="true" />
        <param name="RollingStyle" value="Date" />
        <param name="DatePattern" value=".yyyyMMdd" />
        <layout type="log4net.Layout.PatternLayout">
            <param name="Header" value="" />
            <param name="Footer" value="" />
            <param name="ConversionPattern" value="%date{dd MMM yyyy HH:mm:ss} %message %newline" />
        </layout>
    </appender>
    <!-- This appended logs to audit file -->
    <appender name="Config" type="log4net.Appender.RollingFileAppender">
        <filter type="log4net.Filter.LoggerMatchFilter">
            <loggerToMatch value="Audit" />
            <acceptOnMatch value="false" />
        </filter>
        <filter type="log4net.Filter.LoggerMatchFilter">
            <loggerToMatch value="ConfigLog" />
            <acceptOnMatch value="true" />
        </filter>
        <filter type="log4net.Filter.DenyAllFilter" />
        <file type="log4net.Util.PatternString">
            <converter>
                <name value="folder" />
                <type value="EnterpriseDT.Util.Debug.SpecialFolderPatternConverter" />
            </converter>
            <conversionPattern value="%folder{CommonApplicationData}\Enterprise Distributed Technologies\Complete FTP\logs\Config.log" />
        </file>
        <param name="AppendToFile" value="true" />
        <param name="MaxSizeRollBackups" value="20" />
        <param name="MaximumFileSize" value="5000000" />
        <param name="RollingStyle" value="Size" />
        <param name="StaticLogFileName" value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <param name="Header" value="" />
            <param name="Footer" value="" />
            <param name="ConversionPattern" value="%message %newline" />
        </layout>
    </appender>
    <!-- This appender will store recent message of level information or higher -->
    <appender name="Verbose Logging" type="log4net.Appender.RollingFileAppender">
        <filter type="log4net.Filter.LoggerMatchFilter">
            <loggerToMatch value="Audit" />
            <acceptOnMatch value="false" />
        </filter>
        <filter type="log4net.Filter.LoggerMatchFilter">
            <loggerToMatch value="ConfigLog" />
            <acceptOnMatch value="false" />
        </filter>
        <filter type="log4net.Filter.LevelRangeFilter">
            <levelMin value="VERBOSE" />
            <levelMax value="FATAL" />
        </filter>
        <file type="log4net.Util.PatternString">
            <converter>
                <name value="folder" />
                <type value="EnterpriseDT.Util.Debug.SpecialFolderPatternConverter,CompleteFTPServer" />
            </converter>
            <conversionPattern value="%folder{CommonApplicationData}\Enterprise Distributed Technologies\Complete FTP\logs\Verbose.log" />
        </file>
        <param name="AppendToFile" value="true" />
        <param name="MaxSizeRollBackups" value="20" />
        <param name="MaximumFileSize" value="5000000" />
        <param name="RollingStyle" value="Size" />
        <param name="StaticLogFileName" value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="%date %level %logger %message %newline" />
        </layout>
    </appender>
    <!-- This appender will store recent message of level information or higher -->
    <appender name="Summary Logging" type="log4net.Appender.RollingFileAppender">
        <filter type="log4net.Filter.LoggerMatchFilter">
            <loggerToMatch value="Audit" />
            <acceptOnMatch value="false" />
        </filter>
        <filter type="log4net.Filter.LoggerMatchFilter">
            <loggerToMatch value="ConfigLog" />
            <acceptOnMatch value="false" />
        </filter>
        <filter type="log4net.Filter.LevelRangeFilter">
            <levelMin value="INFO" />
            <levelMax value="FATAL" />
        </filter>
        <file type="log4net.Util.PatternString">
            <converter>
                <name value="folder" />
                <type value="EnterpriseDT.Util.Debug.SpecialFolderPatternConverter,CompleteFTPServer" />
            </converter>
            <conversionPattern value="%folder{CommonApplicationData}\Enterprise Distributed Technologies\Complete FTP\logs\Summary.log" />
        </file>
        <param name="AppendToFile" value="true" />
        <param name="MaxSizeRollBackups" value="20" />
        <param name="MaximumFileSize" value="5000000" />
        <param name="RollingStyle" value="Size" />
        <param name="StaticLogFileName" value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="%date %level %logger %message %newline" />
        </layout>
    </appender>
    <!-- Setup the root category, add the appenders and set the default level -->
    <root>
        <level value="ALL" />
        <appender-ref ref="Verbose Logging" />
        <appender-ref ref="Summary Logging" />
        <appender-ref ref="Audit" />
        <appender-ref ref="Config" />
    </root>
</log4net>
...