I am using following PatternLayout:
%d{HH:mm:ss.SSS} [%T - %F - %c - %M - %L] [%level]- %msg%n"
where
T = ID of the Thread
F = Filename where the logger request was issued
c = name of Logger
M = Method name where logger was issued
L = line number
and calling logger as follows:
log4j_logger = self.spark._jvm.org.apache.log4j # noqa
return log4j_logger.LogManager.getLogger(f"production.{self.__class__.__name__}")
The name of loggers in configuration are production.CLASS_NAMES.
The LogEvent for this [%T - %F - %c - %M - %L] looks like following:
[245 - NativeMethodAccessorImpl.java - production.PreprocessingTask - invoke0 - -2 ]
where
T = 245
F = NativeMethodAccessorImpl.java
c = production.PreprocessingTask
M = invoke0
L = -2
How to get file name where logger was issued, actual line number, actual method function inside class?
Class names are same as logger names.