custom java logging format issues using java.util.logging

I am adding logging facility in my project and i have created a logging class which i am calling everywhere in the project classes and defining level of logging based on requirement. now the issue which i am facing is the way i want the logging to happen. I have written a logger formatting class, the code is given below :

this class is working, but it is not the desired result.

the current logging format is :

whereas my intended format for normal logging is :

As I am using a single class in the project, i am unable to call getSourceClassName() and getSourceMethodName() method on LogRecord object. I dont know if there is any other way for that or not.

the other part of the problem is showing the log in case of error or exception, i have created a method in which i convert the stacktrace to string and pass it to logger class, but again the format is not like what i would like to see. this are the statements i am using :

s ravi chandran wrote:As I am using a single class in the project, i am unable to call getSourceClassName() and getSourceMethodName() method on LogRecord object.

I don't get why you're unable to use the two methods that are created for what you want. If you're using only a single class, then your logs should show only this single class, as there won't be any other source of the exceptions (except maybe API methods called with invalid arguments).

s ravi chandran wrote:As I am using a single class in the project, i am unable to call getSourceClassName() and getSourceMethodName() method on LogRecord object.

I don't get why you're unable to use the two methods that are created for what you want. If you're using only a single class, then your logs should show only this single class, as there won't be any other source of the exceptions (except maybe API methods called with invalid arguments).

well, i am using a class MyLogger, this class is called in all the project classes wherever i am logging something. now if i call getSourceClassName() method, i get the name as MyLogger, and the method name is also from MyLogger class. I am not creating individual logger object in each class, maybe in that way these methods will be useful.