Skip to content
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

Log information in seperate line in log4j. #2936

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shubhamind08
Copy link

Fixes # .Adding a line after each log message.

Did you remember

  • Add test case(s)
  • Update CHANGES.txt
  • Auto applied styling via ./gradlew autostyleApply

We encourage pull requests that:

  • Add new features to TestNG (or)
  • Fix bugs in TestNG

If your pull request involves fixing SonarQube issues then we would suggest that you please discuss this with the
TestNG-dev before you spend time working on it.

Note: For more information on contribution guidelines please make sure you refer our Contributing section for detailed set of steps.

Copy link
Member

@krmahadevan krmahadevan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear as to what we are trying to solve via this PR. System.lineSeparator() merely returns the line separator string that is applicable for the current OS. I believe that character still needs to be consumed in some print statement or a logger for it to be effective no?

@shubhamind08
Copy link
Author

Thanks for writing @krmahadevan . I depends on the version of Java we are using in our machine. If it's above 1.7 then it should work out. Else whatever you said needs to be followed by enclosing in some print statement.

I'll be pulling another request by making sufficient changed into the existing code and then please do let me know..
Thanks for noticing it.

@krmahadevan
Copy link
Member

@shubhamind08

I depends on the version of Java we are using in our machine. If it's above 1.7 then it should work out. Else whatever you said needs to be followed by enclosing in some print statement.

Do you have a sample that you can share with me, where I can see this in action? I was the under the assumption that the line separator is just a platform neutral way of obtaining the line separator, but you still need to be including it in your print or log statements such as

System.out.println(System.lineSeparator()+ "Hello World!");

(or)

logger.info("{} SampleMessage", System.lineSeparator());

Without doing either of the above, I don't think that the line separator is going to get automatically added. I will wait for some more inputs from you to u'stand how you are getting it to work

@shubhamind08
Copy link
Author

Yeah I do have a sample in working using line seperator but meanwhile there's one more way to accomplish it.
Example:-
logger.info(" Hello world \n ");
"\n" inside the logger block does it for us.
Check it by dry running.

@krmahadevan
Copy link
Member

@shubhamind08 - In that case I don't think we would be applying this change within TestNG because that can clutter/elongate the TestNG specific logs. I believe that when you already do logger.info() or logger.warn() etc., each line is printed after a new line is implicitly added. Not sure why we need to add an extra new line to each of the log lines in TestNG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants