I think I misunderstood you.  Yes, you can get java.vm.version and the like as 
system properties but they may not be completely formatted as Gary wishes.

On Sep 18, 2014, at 4:38 PM, Ralph Goers <rgo...@apache.org> wrote:

> It isn't a system property
> 
> Sent from my iPad
> 
> On Sep 18, 2014, at 2:41 PM, Matt Sicker <boa...@gmail.com> wrote:
> 
>> Wouldn't this all be available through the ${sys:*} lookup variables?
>> 
>> On 18 September 2014 12:56, Ralph Goers <ralph.go...@dslextreme.com> wrote:
>> I would recommend adding it as a special Lookup just like hostname is.  Then 
>> in your pattern layout you just need to specify the header as 
>> ${java-version} or ${java-short-version}, etc.
>> 
>> Ralph
>> 
>> On Sep 18, 2014, at 9:51 AM, Gary Gregory <garydgreg...@gmail.com> wrote:
>> 
>>> 
>>> I would like the start of my logs to start with the same information "java 
>>> -version" provides. 
>>> 
>>> On the console, "java -version" says:
>>> 
>>> java version "1.8.0_20"
>>> Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
>>> Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
>>> 
>>> I cook this up manually now from system properties but it sure would be 
>>> nice to ask Log4j to do it for me since 'java -version' is something I am 
>>> sure we are all used to seeing.
>>> 
>>> This could be done with special pre-built Message classes and % markers I 
>>> can also add to the header of a file (or any) appender.
>>> 
>>> I could see a:
>>> 
>>> JavaShortVersionMessage and %JavaShortVersion produce:
>>> java version "1.8.0_20"
>>> 
>>> JavaJreVersionMessage %JavaJreVersion produce:
>>> 
>>> Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
>>> 
>>> JavaVmVersionMessage and %JavaVmVersion produce:
>>> Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
>>> 
>>> In code I could say:
>>> 
>>> logger.debug(new JavaShortVersionMesssage());
>>> logger.debug(new JavaJreVersionMessage());
>>> logger.debug(new JavaVmVersionMessage());
>>> 
>>> In a file appender I could say header="My 
>>> App%n%JavaShortVersionMessage%n%JavaJreVersionMessage%n%JavaVmVersionMessage%n"
>>> 
>>> Or maybe we could have someway to break a header into >1 log event.
>>> 
>>> Thoughts?
>>> 
>>> Gary
>>> 
>>> -- 
>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org 
>>> Java Persistence with Hibernate, Second Edition
>>> JUnit in Action, Second Edition
>>> Spring Batch in Action
>>> Blog: http://garygregory.wordpress.com 
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>> 
>> 
>> 
>> 
>> -- 
>> Matt Sicker <boa...@gmail.com>

Reply via email to