I’d need to see the rest of your main. For example does it declare a Logger? If so where is it in relation to the static block?
Ralph > On Oct 30, 2023, at 7:25 AM, Alex Orlov <ooo_satu...@mail.ru.INVALID> wrote: > > > Hi all, > > I use log4j 2.21.1. This is my xml config file: > > <?xml version="1.0" encoding="UTF-8"?> > <Configuration status="debug"> > <Appenders> > <File name="File" fileName="./../log/log-${sys:foo.test}.txt" > immediateFlush="true" append="false"> > <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} > %highlight{[%level]}{FATAL=bright_red bold, ERROR=red bold, WARN=yellow bold, > INFO=blue bold, DEBUG=green bold, TRACE=magenta bold} [%t] %logger{36} - > %msg%n" disableAnsi="false"/> > </File> > </Appenders> > > <Loggers> > <Root level="debug"> > <AppenderRef ref="File"/> > </Root> > </Loggers> > </Configuration> > > This is a piece of my MainClass: > > public final class MainClass { > > static { > SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd > hhmmss"); > System.setProperty("foo.test", dateFormat.format(new Date())); > } > > ..... > } > > However, the generated log file is `log-${sys:foo.test}.txt`. I mean: > > user@pc:~/Temp/log$ ls > 'log-${sys:foo.test}.txt' > > According to docs > https://logging.apache.org/log4j/2.x/manual/configuration.html#PropertySubstitution > my solution must work but it doesn't. Could anyone say how to fix it? > > > -- > Best regards, Alex Orlov --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org