0

Obviously Java.util.logging is an option but are any other options available (possibly by enabling a feature)? I did see the eventLogging-1.0 feature but I can't find the related jar or docs.

Specifically, I want to provide a unique identifire with some of my logs, similar to how Liberty does it. Example, see CWWK* below

[3/30/17 13:29:27:198 PDT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           A CWWKE0001I: The server defaultServer has been launched.
[3/30/17 13:29:28:638 PDT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           I CWWKE0002I: The kernel started after 1.695 seconds

I could just wrap my calls to Logger.log() and append the ids myself but I figured there has to be a better way. I shouldn't have to include a new lib (ex log4j) since the internal Liberty logs are already doing this.

MDev
  • 127
  • 9

1 Answers1

2

The CWWK* prefix is part of the message in the NLS message files. There is no magic that prepends these ids to the log messages. They only appear for NLS enabled messages, if you look in trace.

The eventLogging feature essentially causes important events to be logged to the messages.log, it isn't providing an application logging API which is why you can't find any documentation on it.

Liberty doesn't provide a logging API, if java.util.logging doesn't work for you then you can use log4j or slf4j by putting those logging libraries in your application.

Alasdair
  • 3,071
  • 15
  • 20
  • 1
    Maybe, it depends what you mean by message.properties. When we output messages to the messages.log or console.log we essentially use a ResourceBundle to resolve a message that is then translated to the server locale. The prefix CWWK* is in the message in the ResourceBundle. ResourceBundles are often .properties files, but in Liberty we use ListResourceBundles, so they are actually in class files. – Alasdair Mar 31 '17 at 22:29
  • Do you mean the message.properties file would look something like this? Key1=CWWKE0001I: The server defaultServer has been launched. Key2=CWWKE0002I: The kernel started after {0} seconds I tried finding the matching bundles to confirm this but could not. I was not expecting this since so many different libraries have the exact same format and each library would have their own resource bundles. – MDev Mar 31 '17 at 22:36
  • Yes, I've normally used .properties files. Is the key automatically incuded in the message when using ListResourceBundles? I guess a custom ListResourceBundles could possibly prepend the key to the message automatically\. – MDev Mar 31 '17 at 22:38
  • No, in our source system we use a properties file and we manually add the message key. There is no magic. Someone wrote the message code by hand. – Alasdair Mar 31 '17 at 22:48