0

I have set my logging.properties with the following and restarted tomcat: com.example.handler.level = FINEST

And I have a method of:

public SearchHistoryItem getSearchHistoryItem(Api1 api1, String stringId, String resultId) {
    SearchHistoryItem item = api1.getSearchHistoryDetails(stringId, resultId);
    Level level = logger.getLevel();
    logger.log(Level.INFO, "Log level is: " + level);
    logger.log(Level.FINEST, "item is: " + item);
    return item;
  }

And a return of the following: 13-Dec-2016 18:32:53.093 INFO [ajp-nio-127.0.0.1-8009-exec-4] com.example.handler.SomeHandler.getSearchHistoryItem Log level is: FINEST

If you note. The first log message prints what I am looking for. So I see that logging is indeed FINEST, and I see that log messages are being written. But I don't see the second log message ever print. Is there something other than setting the level in the properties file that I need to worry about?

UPDATE

I am using java.util.logging.Logger with default configurations as far as I can see.

UPDATE I have been playing with this more and it seems that if I change to Level.FINE they will log. Perhaps there is something somewhere filtering out logs that are to high?

buzzsawddog
  • 662
  • 11
  • 32
  • You should give precisions : logging library you are using and the log configuration. It could help to understand. – davidxxx Dec 13 '16 at 19:08
  • @davidxxx I edited but using the java logging logger with what looks like default configurations in the properties file other than what I added. – buzzsawddog Dec 13 '16 at 19:15
  • It is not directly the subject but `java.util.logging` is not necessarily the best choice. It is not very efficient, the configuration options are very limited and it is not standardized for slf4J. If you have the choice, look at slf4J with Logback or Log4J ? Anyway, I did just an answer. – davidxxx Dec 13 '16 at 19:30
  • @davidxxx at this point in the game switching loggers is not something I can do. I will bring it up to the team later on for a later release :-) Thanks for your answer I found more info there. – buzzsawddog Dec 13 '16 at 20:04

1 Answers1

1

I suppose your problem is with logs in the console.

The used default level for that Handler is Level.INFO. http://docs.oracle.com/javase/6/docs/api/java/util/logging/ConsoleHandler.html

With FileHandler which the used default level is Level.ALL, you would have not had the problem.

Either you set the level for ConsoleHandler programatically, either you set the it in the configuration file (https://docs.oracle.com/cd/E19717-01/819-7753/gcblo/)

This post gives more details about the question : Why are the Level.FINE logging messages not showing?

Community
  • 1
  • 1
davidxxx
  • 125,838
  • 23
  • 214
  • 215