[GitHub] logging-log4j2 pull request #130: How can I use CachedClock

2017-11-16 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/logging-log4j2/pull/130


---


[GitHub] logging-log4j2 pull request #130: How can I use CachedClock

2017-11-14 Thread Hema-Chandra
GitHub user Hema-Chandra opened a pull request:

https://github.com/apache/logging-log4j2/pull/130

How can I use CachedClock 

Sorry, I don't know whether I can ask the question here or not. I am new to 
GitHub. Here is my problem:



0

down vote

favorite


 


According to this log4j2 configuration I am trying to set the 
"log4j2.component.properties" file in my NetBeans project. I have already 
configured my log4j2 with ASYNC_LOGGERS and one thing I particularly need is 
the "log4j.Clock" property. Because I get the data at a very high speed from 
the Servers and we expect that the logging timestamp needs to be perfect. How 
can I use the "log4j2.component.properties" file in my project. Currently I 
created the "log4j2.component.properties" file in my default package of the 
project and set the values as below:

My log4j2.component.properties file

Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
AsyncLogger.RingBufferSize=512*1024
-DAsyncLoggerConfig.RingBufferSize=512*1024
log4j.Clock=SystemClock

My log4j2.xml file
  

  
 
  
%d{-MM-dd HH:mm:ss.SSS} %p %m%n
  
  


  
  



  
%d{-MM-dd HH:mm:ss.SSS} %p %m%n
  
  


  
  


  
  


  
   









Is this correct way of using it? I am highly confused in how to use it. I 
want the timestamp to be perfect and so I want to use the "log4j2.clock" 
parameter set to "org.apache.logging.log4j.core.util.Clock". All I want is 
asynchronous logging with the exact time when the record has reached. But I am 
getting the following exception in trace

run:
ERROR StatusLogger Could not create 
org.apache.logging.log4j.core.util.Clock: java.lang.InstantiationException: 
org.apache.logging.log4j.core.util.Clock, using default SystemClock for 
timestamps.
2017-11-14 18:19:56,696 main DEBUG Initializing configuration 
XmlConfiguration[location=D:\NetBeansProjects\WebApps\Netty_Price_gateway_log4j\build\classes\log4j2.xml]
2017-11-14 18:19:56,712 main DEBUG Installed 1 script engine
2017-11-14 18:19:57,009 main DEBUG Oracle Nashorn version: 1.8.0_144, 
language: ECMAScript, threading: Not Thread Safe, compile: true, names: 
[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], 
factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory
2017-11-14 18:19:57,009 main DEBUG PluginManager 'Core' found 115 plugins
2017-11-14 18:19:57,009 main DEBUG PluginManager 'Level' found 0 plugins
2017-11-14 18:19:57,024 main DEBUG PluginManager 'Lookup' found 13 plugins
2017-11-14 18:19:57,024 main DEBUG Building Plugin[name=layout, 
class=org.apache.logging.log4j.core.layout.PatternLayout].
2017-11-14 18:19:57,024 main TRACE TypeConverterRegistry initializing.
2017-11-14 18:19:57,024 main DEBUG PluginManager 'TypeConverter' found 26 
plugins
2017-11-14 18:19:57,040 main DEBUG 
PatternLayout$Builder(pattern="%d{-MM-dd HH:mm:ss.SSS} %p %m%n", 
PatternSelector=null, 
Configuration(D:\NetBeansProjects\WebApps\Netty_Price_gateway_log4j\build\classes\log4j2.xml),
 Replace=null, charset="null", alwaysWriteExceptions="null", 
disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
2017-11-14 18:19:57,040 main DEBUG PluginManager 'Converter' found 42 
plugins
2017-11-14 18:19:57,056 main DEBUG Building 
Plugin[name=TimeBasedTriggeringPolicy, 
class=org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy].
2017-11-14 18:19:57,056 main DEBUG 
TimeBasedTriggeringPolicy$Builder(interval="null", modulate="null", 
maxRandomDelay="null")
2017-11-14 18:19:57,056 main DEBUG Building 
Plugin[name=SizeBasedTriggeringPolicy, 
class=org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy].
2017-11-14 18:19:57,056 main DEBUG createPolicy(size="500 MB")
2017-11-14 18:19:57,056 main DEBUG Building Plugin[name=Policies, 
class=org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy].
2017-11-14 18:19:57,071 main DEBUG 
createPolicy(={TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, 
modulate=false), SizeBasedTriggeringPolicy(size=524288000)})
2017-11-14 18:19:57,071 main DEBUG Building 
Plugin[name=DefaultRolloverStrategy, 
class=org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy].
2017-11-14 18:19:57,071 main DEBUG 
DefaultRolloverStrategy$Builder(max="50", min="null", fileIndex="null", 
compressionLevel="null", ={}, stopCustomActionsOnError="null", 
tempCompressedFilePattern="null", 
Configuration(D:\NetBeansProjects\WebApps