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

Janardhan Naidu commented on LOG4J2-3454:
-----------------------------------------

Hi [~rgoers] 

Thanks for the response, It helped. 

I have one more question, I am configuring my appender manually using 
ConfigurationBuilder. and I was able to add the required pattern to it. see 
below:

 

LayoutComponentBuilder layoutBuilder = builder.newLayout("PatternLayout")
            .addAttribute("pattern", getLayoutconf());

 

But now, I need to do some customization, that we need to change the 
patternlayout based on the logger name. so I looked into ScriptPatternSelector, 
see below. But I am facing issues, like how we can configure this script 
pattern selector manually using {*}ConfigurationBuilder{*}? please can you 
share an example if any. 
[https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternSelectors] 

 

Thanks in advance!

 

Regards, 

Janardhan 

> how to force rolling file appender to create a new log file every time when 
> we start the application?
> -----------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3454
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3454
>             Project: Log4j 2
>          Issue Type: Question
>    Affects Versions: 2.17.2
>            Reporter: Janardhan Naidu
>            Priority: Major
>
> HI Team, 
>  
> I am in process of migrating the log4j1 to log4j2, where we are rewriting the 
> appenders with the help of AbstractAppender Plugin or using the property 
> file. I have multiple questions regarding this, please help me to resolve the 
> same.
>  # how to force rolling file appender to create a new log file every time 
> when we start the application?  here, consider appenders are configured in 
> property file.
>  # We are rewriting one of the rollingfileappender using the 
> abstractappender/abstractfileappender plugin way, But i am unable to find a 
> method which will get executed before starting of the appender!. in log4j1, 
> we had a method called *checkEntryConditions.* So what is the equalent api in 
> log4j2.?  FYI, we are overriding this method to set all our configurations 
> like backup the old logfile, createnew logger, rolling etc..,
>  # Also, we need to set the ConversionPattern based on the loggername, how we 
> can achieve this.? in log4j1, we were extending patternLayout and overriding 
> the format method to do the same. So how we can acheive this using log4j2? 
>  
> Thanks 
> Janardhan 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to