logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "SIBISH BASHEER (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-695) Custom Logger with restrictions on existing methods
Date Tue, 08 Jul 2014 23:20:05 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-695?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14055651#comment-14055651
] 

SIBISH BASHEER commented on LOG4J2-695:
---------------------------------------

java -jar microbenchmarks.jar -f 5 -wi 10 -i 20 -t 4 
{code}
# Run complete. Total time: 01:23:39
Benchmark                                                Mode   Samples         Mean   Mean
error    Units
c.c.c.p.Log4j12Benchmark.throughput                     thrpt       100   112386.299     4543.005
   ops/s
c.c.c.p.Log4j12Benchmark.throughputBaseline             thrpt       100 4738861083.257 55468703.633
   ops/s
c.c.c.p.Log4j12Benchmark.throughputIsEnabled            thrpt       100 433308960.400  9204820.372
   ops/s
c.c.c.p.Log4j12WrapperBenchmark.throughputBaseline      thrpt       100 4749264744.273 46317303.687
   ops/s
c.c.c.p.Log4j12WrapperBenchmark.throughputStructured    thrpt       100    50904.272     2044.930
   ops/s
c.c.c.p.Log4j2Benchmark.throughput                      thrpt       100    99690.693    29654.376
   ops/s
c.c.c.p.Log4j2Benchmark.throughputBaseline              thrpt       100 4756797101.406 35854163.938
   ops/s
c.c.c.p.Log4j2Benchmark.throughputIsEnabled             thrpt       100 633157648.313  5686563.769
   ops/s
c.c.c.p.Log4j2WrapperBenchmark.throughputBaseline       thrpt       100 4704900738.763 63619511.103
   ops/s
c.c.c.p.Log4j2WrapperBenchmark.throughputSimple         thrpt       100   122735.891    26569.864
   ops/s
c.c.c.p.Log4j2WrapperBenchmark.throughputStructured     thrpt       100    73879.426    10855.105
   ops/s
c.c.c.p.Log4j12Benchmark.latency                       sample   3490099    40547.040     5392.103
   ns/op
c.c.c.p.Log4j12Benchmark.latencyBaseline               sample   6279291       42.875     
  0.076    ns/op
c.c.c.p.Log4j12Benchmark.latencyIsEnabled              sample   4650332       56.905     
  0.135    ns/op
c.c.c.p.Log4j12WrapperBenchmark.latencyBaseline        sample   6376188       42.560     
  0.060    ns/op
c.c.c.p.Log4j12WrapperBenchmark.latencyStructured      sample   5823853    75424.681     
643.447    ns/op
c.c.c.p.Log4j2Benchmark.latency                        sample   1688821    78707.609    21965.050
   ns/op
c.c.c.p.Log4j2Benchmark.latencyBaseline                sample   6358698       42.198     
  0.076    ns/op
c.c.c.p.Log4j2Benchmark.latencyIsEnabled               sample   6411236       53.020     
  0.076    ns/op
c.c.c.p.Log4j2WrapperBenchmark.latencyBaseline         sample   6288066       42.375     
  0.061    ns/op
c.c.c.p.Log4j2WrapperBenchmark.latencySimple           sample   2658330    54565.071    16744.148
   ns/op
c.c.c.p.Log4j2WrapperBenchmark.latencyStructured       sample   4027421    63854.342    10574.658
   ns/op
c.c.c.p.UUIDBenchmark.latencyBaseline                  sample   6377216       42.248     
  0.067    ns/op
c.c.c.p.UUIDBenchmark.latencyJavaUtilUUID              sample   2717835    41209.980     
475.653    ns/op
c.c.c.p.UUIDBenchmark.latencyLog4jUuidUtil             sample   4279253      780.698     
 16.574    ns/op
{code}

> Custom Logger with restrictions on existing methods
> ---------------------------------------------------
>
>                 Key: LOG4J2-695
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-695
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API
>            Reporter: SIBISH BASHEER
>              Labels: customlogger
>             Fix For: 2.0-rc2
>
>         Attachments: AppAsyncMain.java, CustomLogger.java, CustomLogger.java, complete
project.zip, final code V2 7 2 2014.zip, final code custom logger.zip, jmh-based-perf-tests.zip,
performance log4j vs log4j2.zip, performance log4j vs log4j2.zip, performance log4jvslog4j2
singleclass.zip, to Ralph performance code.zip
>
>
> I have been looking at the Custom/Extended logger discussions. But none of them seems
to fulfil what i am looking for.
> 1) I want custom methods as below:
> {code}
>     private static CustomLogger logger = CustomLogger.getLogger(AppAsyncMain.class);
>    
>     logger.info( transaction_id, app_name + event_name +
> 					"inside the loop" + "inside the loop of the sample app" +
> 					"success" + "looped in" + "loop_count" +
> 					String.valueOf(i));
> {code}
> 					
> 	log:
> {code}
> 2014-06-30 16:09:28,268 log_level="INFO" thread_name="main" class_name="com.custom.samplelog4j.AppAsyncMain"
transaction_id="79ea1071-9565-405a-aa18-75d271694bf2" event_id="dd5c69c0-4400-41fd-8a2e-5d538d8e8c9b"
app="Sample Logging SDK App" event_name="Sample Event" action="start of sample app" desc="start
of api" result="success" reason="start" token="abcdefg" alias="abc@gmail.com" 
> {code}
> 	
> 2) I want to show warning in existing logger methods so the teams using the custom logger
doesn't use these methods other than for testing:
> {code}
>    logger.info("start of statement");
> {code}
>    
>    log:
> {code}
>    2014-06-30 16:12:31,065 log_level="INFO" thread_name="main" class_name="com.custom.samplelog4j2.AppAsyncMain"
start of statement  customlogger_warning="method not recommended for production use" 
> {code}
>    
> 3) Custom validations for the fields:
> {code}
>     	private static String validateFields(String app_name, String event_name,
> 			String action, String desc, Result result, String reason) {
> 		String validateStatus = "";
> 		if (!ValidateAppName(app_name)) {
> 			validateStatus = "app_name";
> 		} else if (!ValidateEventName(event_name)) {
> 			validateStatus = "event_name";
> 		} else if (!ValidateAction(action)) {
> 			validateStatus = "action";
> 		} else if (!ValidateDesc(desc)) {
> 			validateStatus = "desc";
> 		} else if (!ValidateReason(result, reason)) {
> 			validateStatus = "reason";
> 		}
> 		return validateStatus;
> 	}
> {code}
> Options tried:
> 1.
> * extended ExtendedLoggerWrapper
> * created the map of the Custom logger
> * This option was failing because of "writing to a closed appender"
> * Attached is the code "CustomLogger.java"
>    
> 2. Modified the AbstractLogger in Trunk and added the below methods:
> {code}
>       @Override
>     public void info(final String message) {
>     String updtMessage = message + " amexlogger_error=\"Incorrect method used\"";
>         logIfEnabled(FQCN, Level.INFO, null, updtMessage, (Throwable) null);
>     }
>  public void info(final String transactionId, final String app_name, final String event_name,
final String action, final String desc, final String result, final String reason, final String...
moreFields) { 
>        String message = "transaction_id=" + transactionId + " " + "app_name=" + app_name
+ " " + "event_name=" + event_name + " " + "action=" + action;
>  
>         logIfEnabled(FQCN, Level.INFO, null, message, (Throwable) null);
>     }
> {code}
> 	I don't want to modify the methods inside the log4j-api. 
> 	
> Please help me with the correct approach on how to use log4j2 for this usecase.
> Thanks
> Sibish



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message