tag:blogger.com,1999:blog-8712770457197348465.post3956033974824366524..comments2024-03-19T05:51:39.935-07:00Comments on Javarevisited: Top 10 Tips on Logging in Java - Tutorialjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger31125tag:blogger.com,1999:blog-8712770457197348465.post-14258007303790530672018-05-18T06:07:19.106-07:002018-05-18T06:07:19.106-07:00Hi,
Great article. Is there an 'easy' way ...Hi,<br />Great article. Is there an 'easy' way to ensure that every message that is logged is fully santized? e.g i want everything logged to be encoded via ESAPI.encoder().encodeForHTML(). Does slf4j do any santization as part of its parameter substitution via the {} ? Thanks for all info.<br />JohnJohn Harkinhttps://www.blogger.com/profile/09332291903077301750noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-57175003340253972032014-07-15T02:06:00.102-07:002014-07-15T02:06:00.102-07:00hi all, had anyone knows about logback despite usi...hi all, had anyone knows about logback despite using log4j and sl4j? how this logback are progress? can anyone help me to summarize it? does this type are the same formatting, logging outputs with log4j and sl4j?tudungdimensihttps://www.blogger.com/profile/02890134983205471505noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-79805410063346052132014-03-18T06:28:58.558-07:002014-03-18T06:28:58.558-07:00By having code in an 'isDebugEnabled()' yo...By having code in an 'isDebugEnabled()' you are making your test/development and production purposely execute differently. I have seen this cause a problem in production code that we were unable to replicate in test or development. You also advocate always doing this, regardless of whether any excessive iteration or processing will occur. More code, especially code not related to the Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-3223009100698994002014-03-15T14:16:30.013-07:002014-03-15T14:16:30.013-07:00Tip #0 for developers when it comes to logging: Go...Tip #0 for developers when it comes to logging: Go and talk to the people in operations and service desk and ask them what kind of problems they have today when trying to applications up and running. Ask them how better logging might help them. Ask them what they are missing in todays logs. Ask to see examples of insufficient logging. <br /><br />Then you can go back to your desk and discuss if Jan Andersenhttps://www.blogger.com/profile/13496684660724508617noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-86561753172163482432013-09-29T23:11:23.300-07:002013-09-29T23:11:23.300-07:00One of the best tips in logging is don't log t...One of the best tips in logging is don't log too much, it will make your application slow. If you still need to logging lot of data then consider using Async logger from log4j 2.0. It's still in beta but it really fast and very suitable for high frequency low latency application, which needs to log every incoming and outgoing messages.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-58750602795953842872013-04-08T07:27:06.337-07:002013-04-08T07:27:06.337-07:00Hi,
I found this via your comment at "http:/...Hi,<br /><br />I found this via your comment at "http://article-stack.com/education/how-to-use-log4j-an-efficient-and-sufficient-guide-with-examples.amty".<br /><br />I believe this is really well written - but not suitable for beginners like me. The starting is really easy to understand and I hope the rest will make more sense for me after working with more examples. <br /><br />ThanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-17605303272702472302013-01-03T00:32:58.854-08:002013-01-03T00:32:58.854-08:00Here is my logging tips on What to log and don'...Here is my logging tips on What to log and don't log for Java programmers :<br /><br />1) Don't log sensitive information e.g. SSN number, Credit Card number in log file.<br /><br />2) Don't log user input without sanitizing it. e.g. user may enter some data which can jeopardize log e.g. entering CRLF or CR which can split one log line into multiple and confuse support staff. <br /><Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-75227392566321091962012-12-04T16:00:29.313-08:002012-12-04T16:00:29.313-08:00Java Util Logging (JUL) log level can be changed @...Java Util Logging (JUL) log level can be changed @ runtime in case of Jboss 7 (via jmx/console). No code changes required.<br /><br />http://www.techiesinfo.com/Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-40450251117739232052012-12-04T00:04:45.874-08:002012-12-04T00:04:45.874-08:00Nice post .
logger.debug("No of Executions {...Nice post . <br />logger.debug("No of Executions {} for clients:{}"<br /><br /> , noOfOrder , client); // faster<br />But ,I am getting error when i use this line . <br />//The method debug(Object, Throwable) in the type Category is not applicable for the arguments (String, int, int)<br /><br /><br />Sirishahttps://www.blogger.com/profile/09368433551917691673noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-27143272967191284182012-07-21T12:05:51.774-07:002012-07-21T12:05:51.774-07:00Great post to get to know about various logging pi...Great post to get to know about various logging pitfalls. If at all anyone wants to know how this is implemented, I have written on how to implement basic logging using log4j in Java at http://programmingfree.blogspot.in/2012/07/implement-logging-with-log4j-in-java.html.Anonymoushttps://www.blogger.com/profile/14387354000463854833noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-6563999938247489232012-06-26T07:54:22.592-07:002012-06-26T07:54:22.592-07:00@Sathish, you are right here. Some Web server, esp...@Sathish, you are right here. Some Web server, especially WAS(IBM Websphere ) logs all System.out.println statement in System.out file but that is something very specific to managed J2EE environments, while logging is much broader and applicable especially for core Java servers. but if you look at System.out statements they are not as rich in functionality as any logging framework like Log4j or Javin @ spring questions in Javahttp://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-67445365520681636742012-06-25T18:54:56.024-07:002012-06-25T18:54:56.024-07:00Thanks for the info.
I need a clarification here....Thanks for the info.<br /><br />I need a clarification here. If we use System.out.println, it still writes the information in a separate file called 'System.out' in the application servers. So how using Sysout affects performance wise when compared to the other loggers.Sathishhttps://www.blogger.com/profile/06576087741337260277noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-10187765761709208112012-06-25T14:34:29.594-07:002012-06-25T14:34:29.594-07:00I would also add number 12:
Use good log viewer. I...I would also add number 12:<br />Use good log viewer. I'm using OtrosLogViewer because I have SOAP messages in logs.Anonymoushttps://www.blogger.com/profile/04880883396368840576noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-16732019358901334142012-05-28T06:59:24.034-07:002012-05-28T06:59:24.034-07:00Thanks for reminding me that.
I found out my self...Thanks for reminding me that.<br /><br />I found out my self after actually trying logger, it was the example containing no concatenation at all that misled me:<br /><br />if(logger.isDebugEnabled()){<br />logger.debug("java logging level is DEBUG Enabled");<br />}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-7106569705115547252012-05-26T12:15:48.844-07:002012-05-26T12:15:48.844-07:00Lê Ngọc Minh, concatenation is done before message...Lê Ngọc Minh, concatenation is done before message gets inside of debug method because Java like most programming languages calculates arguments before passing them into method. isDebugEnabled() prevents this if concatenation is guarded by it. Still, I think that it is generally very bad advice to use it everywhere, because you get a lot of clutter in your code. This is a kind of premature Rorickhttps://www.blogger.com/profile/02909060763732064890noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-19185590546859746202012-05-01T08:41:27.399-07:002012-05-01T08:41:27.399-07:00I think log4j is intelligent enough to check debug...I think log4j is intelligent enough to check debug enabled before doing any string concatenation. Please have a look at debug() documentation or Logger.java, Category.java in log4j source package.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-78989511661331176382012-03-18T22:34:29.570-07:002012-03-18T22:34:29.570-07:00Very informative and useful tips on logging in Jav...Very informative and useful tips on logging in Java. I agree that programmer often undermine advantages of logging accurate information in precise and consistent, readable format.Andreinoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-25797814258577395322012-03-12T05:09:26.110-07:002012-03-12T05:09:26.110-07:00Useful article. Thanks.Useful article. Thanks.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-36349373366074331032011-11-07T10:24:57.692-08:002011-11-07T10:24:57.692-08:00Nice post. Covered almost every aspect of it. Than...Nice post. Covered almost every aspect of it. Thanks.Anonymoushttps://www.blogger.com/profile/16335275017896132892noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-9140443052009690562011-09-19T02:26:28.398-07:002011-09-19T02:26:28.398-07:00I have been recommended to use log4j by my archite...I have been recommended to use log4j by my architect. Perviously i have been used slf4j, i am not in a position to ask why log4j why not slf4j, can any one guess why he suggest log4jAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-70323798244116504732011-08-04T18:53:39.376-07:002011-08-04T18:53:39.376-07:00logging, logging and logging I really don't un...logging, logging and logging I really don't understand why so much cry over Java logging. there are many java logging API out there just go and use them ?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-59860989035964974882011-07-27T18:18:48.615-07:002011-07-27T18:18:48.615-07:00SL4j, Log4j are the best solution for implementing...SL4j, Log4j are the best solution for implementing logging for java project. though you can use JDK logging API, Log4j logging is better.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-78302506618462323522011-07-12T08:59:33.591-07:002011-07-12T08:59:33.591-07:00I agree with Eric, Jiri and the others: SLF4J is ...I agree with Eric, Jiri and the others: SLF4J is the way to go. I use it in everything now. I don't even bother with using commons-logging, JULI, or log4j directly any more.<br /><br />And thanks for commenting on http://shrubbery.mynetgear.net/c/display/W/Routing+java.util.logging+messages+to+Log4Jjoshejoshhttps://www.blogger.com/profile/13081804761104798727noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-22175566429362778872011-06-02T09:53:32.765-07:002011-06-02T09:53:32.765-07:00Excellent article! One best practice you missed is...Excellent article! One best practice you missed is to always code against a wrapper (slf4j or commons-logging) which allows you to swap logging implementations. Although log4j is still viable, logback has several useful improvements. I'd recommend logback over log4j nowadays.Ericnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-63298627242127072442011-05-04T13:36:29.663-07:002011-05-04T13:36:29.663-07:00slf4j is actually not a logging library - it's...slf4j is actually not a logging library - it's just a facade. You choose a logging framework by yourself. We use slf4j and logback that implements the slf4j API natively. Both libraries are written by Ceki Gülcü who is also the author of log4j - logback is intended as a successor to log4j (both are very similar).Jiří Pejchalnoreply@blogger.com