I want to output a log message exactly the way it is done using the bash "logger" command, but in Java using Log4j:
Feb 5 19:35:28 hostname program: mymsg
After trying many different patterns, I cannot reproduce the same output. Any idea how to write a pattern for this?
Thank you,
I am guessing you'll get host name from system variables or environmental variables because there is no default parameter for hostname in log4j. So let's assume you'll get hostname and program name from sys variables. So the pattern would be :
<PatternLayout pattern="%d{MMM d HH:mm:ss} ${sys:user.home} ${sys:program}: %m%n" />
See the reference