[ 
https://issues.apache.org/jira/browse/LOG4J2-326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13723888#comment-13723888
 ] 

Sudharma Puranik commented on LOG4J2-326:
-----------------------------------------

{noformat}
<Routes pattern="$${ctx:fruits}">
                                <Route key="apple">
                                        <RollingFile 
name="Rolling-${ctx:fruits}" fileName="logs/apple-${ctx:fruits}.log"
                                                
filePattern="./logs/${date:yyyy-MM}/apple-%d{yyyy-MM-dd}-%i.log.gz">
                                                <PatternLayout>
                                                        <pattern>%d{ISO8601} 
[%t] %p %c{3} %L - %m%n</pattern>
                                                </PatternLayout>
                                                <Policies>
                                                        
<TimeBasedTriggeringPolicy interval="6"
                                                                modulate="true" 
/>
                                                        
<SizeBasedTriggeringPolicy size="10 MB" />
                                                </Policies>
                                        </RollingFile>
                                </Route>
                                <Route>

                                        <RollingFile name="SUMMARY_ALL" 
fileName="./logs/css-summary.log"
                                                
filePattern="logs/$${date:yyyy-MM}/summary-%d{yyyy-MM-dd-HH}-%i.log.gz">
                                                <PatternLayout>
                                                        <pattern>%d{ISO8601} 
[%t] %p %C{1} %L - %m%n</pattern>
                                                </PatternLayout>
                                                <Policies>
                                                        
<TimeBasedTriggeringPolicy interval="6"
                                                                modulate="true" 
/>
                                                        
<SizeBasedTriggeringPolicy size="10 MB" />
                                                </Policies>
                                        </RollingFile>

                                </Route>
                                <Route key="$${ctx:fruits}">
                                        <RollingFile 
name="Rolling-${ctx:fruits}" fileName="logs/other-${ctx:fruits}.log"
                                                
filePattern="./logs/${date:yyyy-MM}/${ctx:fruits}-other-%d{yyyy-MM-dd}-%i.log.gz">
                                                <PatternLayout>
                                                        <pattern>%d{ISO8601} 
[%t] %p %c{3} %L - %m%n</pattern>
                                                </PatternLayout>
                                                <Policies>
                                                        
<TimeBasedTriggeringPolicy interval="6"
                                                                modulate="true" 
/>
                                                        
<SizeBasedTriggeringPolicy size="10 MB" />
                                                </Policies>
                                        </RollingFile>
                                </Route>
                        </Routes>

{noformat}

I tried this and it does not work. What I mean is that, Is it mandatory that I 
have to add default value to ThreadContext? 

{noformat}
public static void main(String[] args) {
                ThreadContext.put("fruits", "apple");
                logger.info("This message is written to a new file with 
requestId in the file name");
                logger.info("Another message written to that same file");

                for (int i = 0; i <= 5000; i++) {
                        logger.debug(" Loop 1 " + i);
                }
                ThreadContext.remove("fruits");

//               ThreadContext.put("fruits", "orange");
                logger.info("This message is written to a new file with 
requestId in the file name");
                logger.info("Another message written to that same file");

                logger.debug("Sudharma Tested");
                for (int i = 0; i <= 500000; i++) {
                        logger.debug("Loop 1 " + i);
                }
                logger.info("This message is written to the default log file");

        }

 {noformat}


                
> request to improve the RoutingAppender
> --------------------------------------
>
>                 Key: LOG4J2-326
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-326
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Appenders
>            Reporter: Sudharma Puranik
>
> Routing Appender has to be improved in a way that it can handle default 
> appenders in a better way.! Please refer this JIRA for more details
> https://issues.apache.org/jira/browse/LOG4J2-314

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to