how to use log4j in Multithread using java?

后端 未结 5 1573
情深已故
情深已故 2020-12-19 13:40

I want to write log for each thread using log4j and log file name will be \"workthread..log\",first thread print log on file \"workthread-1.log\" and second thread on \"work

5条回答
  •  轮回少年
    2020-12-19 14:22

    you could use MDC

    MDC.put(key,value); --in the code

    and %X{key}-- in the file name field in the log4j configuration file

提交回复
热议问题