<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>

    <appender name="DEFAULT" class="org.apache.log4j.DailyRollingFileAppender">

        <param name="File" value="logs/openbis_log.txt" />
        <param name="DatePattern" value="'.'yyyy-MM-dd" />

        <layout class="org.apache.log4j.PatternLayout">
            <!--
                // %d: outputs the date of the logging event.
                // %-5p: priority (i.e. level) of the logging event should be left justified to
                //       a width of five characters.
                // %t: outputs the name of the thread that generated the logging event.
                // %c: outputs the category of the logging event.
                // %m: outputs the application supplied message associated with the logging event.
                // %X: outputs the MDC (mapped diagnostic context) associated with the thread that generated the logging event.
            -->
            <param name="ConversionPattern" value="%d %-5p [%t]%X{sessionInfo} %c - %m%n" />
        </layout>

    </appender>
    <appender name="AUTH" class="org.apache.log4j.DailyRollingFileAppender">

        <param name="File" value="logs/openbis_auth_log.txt" />
        <param name="DatePattern" value="'.'yyyy-MM-dd" />

        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p [%t]%X{sessionInfo} %c - %m%n" />
        </layout>
    </appender>

    <appender name="USAGE" class="org.apache.log4j.DailyRollingFileAppender">

        <param name="File" value="logs/openbis_usage_log.txt" />
        <param name="DatePattern" value="'.'yyyy-MM-dd" />

        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p [%t]%X{sessionInfo} %c - %m%n" />
        </layout>
    </appender>

    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p [%t] %c - %m%n" />
        </layout>
    </appender>

    <!--
        // Defined but not used right now.
    -->
    <appender name="NULL" class="org.apache.log4j.varia.NullAppender" />

    <appender name="EMAIL" class="org.apache.log4j.net.SMTPAppender">

        <param name="BufferSize" value="512" />
        <param name="SMTPHost" value="localhost" />
        <param name="From" value="screening-openbis@localhost" />
        <param name="To" value="openbis@localhost" />
        <param name="Subject" value="ATTENTION: Screening openBIS Server" />
        <param name="EvaluatorClass"
            value="ch.systemsx.cisd.common.logging.AlwaysTrueTriggeringEventEvaluator" />

        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p [%t] %c - %m%n" />
        </layout>

    </appender>

    <!--
        // If we have the category 'NOTIFY' and we send a logging event with priority 'info', then an email will be sent.
    -->
    <category name="NOTIFY">
        <priority value="info" />
        <appender-ref ref="DEFAULT" />
        <appender-ref ref="EMAIL" />
    </category>
    
    <!--
        // If we have the category 'AUTH' and we send a logging event with priority 'info', then log to AUTH and USAGE.
    -->
    <category name="AUTH">
        <priority value="info" />
        <appender-ref ref="AUTH" />
        <appender-ref ref="USAGE" />
    </category>

    <!--
        // If we have the category 'TRACKING' and we send a logging event with priority 'info', then log to USAGE.
    -->
    <category name="TRACKING">
        <priority value="info" />
        <appender-ref ref="USAGE" />
    </category>

    <!--
        // If we have the category 'ACCESS' and we send a logging event with priority 'info', then log to USAGE.
    -->
    <category name="ACCESS">
        <priority value="info" />
        <appender-ref ref="USAGE" />
    </category>
    
    <!-- 
        // Do not use log level debug otherwise plain passwords are readable.
    -->
    <logger name="httpclient.wire">
        <level value="ERROR" />
    </logger>

    <root>
        <priority value="info" />
        <appender-ref ref="DEFAULT" />
    </root>

</log4j:configuration>
