-
Notifications
You must be signed in to change notification settings - Fork 367
Unable to print the proper package and method name #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@GangadharanS can you provide more information on your configuration and implementation please? It would be very helpful to know what your current ESAPI.properties configuration values are:
These are used in the SLF4JLogFactory for determining what the prefix information will be. Next, can you offer a code snippet for how you are instantiating the Logger instance in your code? The parameter supplied to the method is used as the base logger name.
Last, are you backing SLF4J with Log4j2, Logback, or other? Can you provide the configuration you're setting for the log output for that tool as well? Using this information I believe we should be able to replicate your results and hopefully provide more insight and assistance. |
Hi @jeremiahjstacey , Logger.ApplicationName=ObjectRegistry org.owasp.esapi.Logger logger = ESAPI.getLogger(AccountService.class); logger.info(logger.EVENT_UNSPECIFIED, ">>> Entering Method >>>"); AND inlogback.xml |
@GangadharanS Thanks for the information! I will try to get something setup to emulate this configuration and get back with you as soon as I can. |
Thanks a lot @jeremiahjstacey. for your help. |
What I have done:
Running the test in this configuration appears to reflect your findings. I am not overly familar with the logback syntax, and so I did some general "getting started" searches for some alternative output patterns. I found one that offers a different result: Updating my logback.xml file to the following content:
I get output more aligned with what I think you're wanting. Please note the absence of the slf4j class references below.
Unfortunately, I do not believe there is anything that the ESAPI baseline can offer to address the concern, as I currently understand it. I believe that the output you're seeing is a result of the pattern being applied in your logback.xml configuration. If it were a result of the ESAPI baseline I would have expected the problematic SLF4J file references to persist. Please let me know if I've misunderstood the request intention and I can take another look. |
thanks @jeremiahjstacey. am just getting this Not the one u mentioned. ("[EVENT UNSPECIFIED Anonymous:@unknown -> /ObjectRegistry/org.owasp.esapi.logging.slf4j.SimpleLogbackTest]" - this is missing in my log) Also i need the method and line number to be printed. it prints - WARN [2020-08-19 06:08:44,625] [http-nio-8080-exec-12] com.trimble.oculus.core.services.account.AccountService.log.49 - >>> Entering Method >>> where as methodname and line number are wrong. |
Initial investigation suggests that logback is using the first reference from the call stack to determine the line information to write to the log. Based on what I'm seeing, I think that clients will need to customize the pattern layouts used to inspect farther back in the stack to see the base class information rather than the ESAPI support classes. This can be illustrated by applying my configuration from my comment above, and updating the pattern to use the
Running the listed test with this configuration shows:
It seems like the information is available, but may require more customized parsing/formatting options to extract the data. The last four calls of the stack should be consistent with uses of SLF4J and Logback. @kwwall @xeno6696 - Do either of you have more experience with the configuration for logback, or suggestions on how to move forward? This configuration should be consistent for uses of ESAPI and logback, but I don't think it belongs in the ESAPI baseline. The code is acting as intended, but appears to have a side effect with an assumption in the Logback implementation - which appears to be the logger is called directly from the source code with no intermediaries. @GangadharanS I'll keep looking, but the short answer I see is to write your own |
thanks @jeremiahjstacey but "[EVENT UNSPECIFIED Anonymous:@unknown -> /ObjectRegistry/org.owasp.esapi.logging.slf4j.SimpleLogbackTest]" - ESAPI.Logger.EVENT TYPE and application name info is also missing in my log. |
The message you posted starts with
(see line 133 of the Logger.java class below) It also contains your application name in the server information segment
This output is working as intended, unless I'm misunderstanding. |
Yes, @jeremiahjstacey. Seems working fine for you. can u please share your ESPAI.properties what you have tried to reproduce this. |
This is the base file I'm using. I have set the LogFactory to the slf4J configuration
I have matched the configuration you provided in your comment above
The rest of the configuration is still using the content I outlined in my previous comment |
@jeremiahjstacey Am doing the same but in my log EVENT TYPE and application name info are missing.. WARN [2020-08-19 15:02:21,477] [http-nio-8080-exec-14] Caller+4 at com.trimble.oculus.core.services.account.AccountService.createAccounts(AccountService.java:190) - >>> Entering Method >>> Not sure, what i am missing in configuration. |
@jeremiahjstacey wrote:
I have reviewed logback configurations to look for potential security issues, but not for anything like this. What I suggest once we figure out a way this ought to look for logback, is that we create a new GitHub wiki page on this repository to document it. But beyond that, I agree, I don't think we should be in the business of making various logging configuration files part of the ESAPI (configuration) distribution. |
@jeremiahjstacey - Are you also using the ESAPI 2.2.0.0 release or some other later version? We should rule that out as well in case there were minor fixes to 2.2.1.0 or 2.2.1.1 that is causing this. Also, are you and @GangadharanS both using the same version of logback? That might matter as well. Also, @GangadharanS, are yiou using the ESAPI Logger directly, or do you have it "wrapped" in some additional layers? If it is as @jeremiahjstacey says with logback that is looking at the callstack, the logback.xml file may need further tweaks if you are wrapping the calls to the ESAPI logger in additional layers. |
@kwwall yes am using the logback version 1.2.3 what @jeremiahjstacey tried. and I am using ESAPI logger directly. I can do tweaks in logback to get the pattern. But my question is EVENTTYPE itself not printed in log. I understand this doesnot have anything to do with logback.xml |
@kwwall, I have been adding unit tests to the latest develop branch updates locally. I'm probably closer to the 2.2.1.1 content. @GangadharanS would it be possible to for you update to the latest ESAPI release and see if that changes the output? |
I'm going to be a little pressed the next few days. I intend to set up another local project with my listed configurations and run that unit test with the last three ESAPI releases rather than through my current clone of the baseline. I'm hoping to be able to get that information nlt Sunday. |
@GangadharanS, I was able to go through some preliminary testing. It appears that I have similar results when using v2.2.0.0. The issue regarding Event Type appears to be resolved as of 2.2.1.0 + If you are using v2.2.0.0, please try to update and see if it changes what you're seeing. The results of my testing are listed below. I am still using my test pattern in logback.xml
|
Thanks a lot @kwwall @jeremiahjstacey . let me try upgrading it. |
@jeremiahjstacey I am getting EVENTTYPE in log after upgrading ESAPI to 2.2.1.1. |
Without digging too deep, the
I know that's not quite as nice as the default logback configuration, but it should consistently provide both the method and line number of your source code. |
Reading through the Logback Layout documentation, I found the instructions for a Custom Conversion Specifier This lets you control specific formatting options. First, you will need to create a Conversion class implementation. The API is all included in logback-classic dependency.
Then you need to define your converter in your logback.xml
Here is my full logback.xml file. Note that I've updated the pattern to only use my converter in this example.
Now when I run my same test I receive the following output:
You should be able to use this premise to adjust the Method and line number information however you would desire. |
I believe all concerns of this issue have been discussed and mitigated. |
Hi ,
I am using ESAPI 2.2.0.0 with slf4j logger..
I am getting log like below..
INFO [2020-08-18 07:41:38,398] [XXXXX-XXXX] [http-nio-8080-exec-8] org.owasp.esapi.logging.slf4j.Slf4JLogLevelHandlers$3.log.65 - >>> Entering Method>>>
Instead of logging slf4j package name.. I should be getting my application packagename and class name.
Any immediate help would really be appreciable.
The text was updated successfully, but these errors were encountered: