Hi all,

Searching in documentation i didn't find (or wrong search) an example to separate log files based on its level.


The idea is to have separate files named based on its level, so all error messages will be redirected to "somefile-error.log", info to "somefile-info.log", and so on... with relative additivity property.

I suppose to use a <Routing> tag, but...how to iterate over message level (which lookup should i use)?

My example:

<Configuration status="fatal">
    <Appenders>
        <Routing name="Routing">
            <Routes pattern="$${some_message_level_variable}">
                <Route>
<RollingFile name="RollingFile-${some_message_level_variable}" fileName="the/path/logs/somefile-${some_message_level_variable}.log" filePattern="the/path/logs/somefile-${some_message_level_variable}-%d{yyyy-MM-dd}-%i.log.gz">
                        <PatternLayout>
                            <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
                        </PatternLayout>
                        <Policies>
                            <TimeBasedTriggeringPolicy />
                        </Policies>
                        <DefaultRolloverStrategy/>

<ThresholdFilterlevel="${some_message_level_variable}"/>

                    </RollingFile>
                </Route>
            </Routes>
        </Routing>
        <Console name="STDOUT" target="SYSTEM_OUT">
            <PatternLayout>
                <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
            </PatternLayout>
        </Console>
    </Appenders>
    <Loggers>
        <Root level="warn">
            <AppenderRef ref="Routing"/>
            <AppenderRef ref="STDOUT"/>
        </Root>
    </Loggers>
</Configuration>


Ideas on which property lookup should i use instead of ${some_message_level_variable}??


A note: the best would be to not set any variable in ThreadContext and/or *Map map......


Thanks for your patience,

Best regards,

Agharta












Reply via email to