Search code examples
javalog4jlog4j2

UpperCase Hostname in Log4j


Good morning. I have a problem to UpperCase the name of a file with the hostname. I'm trying to configure with this:

<Property name="example">$$upper{${hostName}}</Property>
...
<RollingFile name="RA.FileAppender" fileName="${example}_%d{yyMMdd}.log" filePattern="${example}_%d{yyMMdd}_%02i.log.gz">

But this doesn't work. This is the name of file

$$upper{RealHostName}_%d{yyMMdd}.log

How can does this work? Thanks and regards


Solution

  • Finally, this works!

    <Property name="example">Logs_${upper:${hostName}}_${date:yyMMdd}</Property>
    

    The problem was 'upper:' and 'date:', with this change the name is replacing correctly :)