will invoke #toString() only when they need. It also makes log format intuitive. Logging library will concat them only when they need. No need to wrap by if(logger.isXxxEnabled()){…}
(e.g. credit card number). Ensure that your framework logs exceptions thrown by your code, or you’ll lose valuable information. Too many log makes system really slow, costly and hard to maintain. Use proper log level to reduce needless logs.
system. It might affect performance of system. Basically disabled in production env but we may enable it only in specific class/package. info log: To log data which should be checked by system or administrator later. It should not affect performance of system. warn log: To tell minor problem to system and/or administrator. The definition of ‘minor’ depends on development policy or log monitoring policy. error log: To tell major problem to system and/or administrator. The definition of ‘major’ depends on development policy or development policy or log monitoring policy. fatal log: To tell severe problem to system and/or administrator. The definition of ‘severe’ depends on development policy or log monitoring policy. Really complex and many ‘it depends’
collector)? Then use INFO, WARN, ERROR or FATAL. Others are only for developers. Understand your policy to monitor logs, then you will find proper level for your log. If you have no policy to decide log level yet, refer Log4j’s definition for each levels.