3

I would like to log in android (mostly for debug purposes) with the method name being automatically detected as I am used to in log4j in other java apps.

However I heard that setting up log4j might be not that easy in android enviroment.

Also logcat is a bit different then just normal console and maybe I would like to use the 'tag' column for method name.

I know I can get StackTraceElement to find out info about the method and line and also use it to write my custom logger or extend the functionality of android Log utility. However this is not a way I want to go and I would like to know if there is sensible way to have nice & effective custom logging in android without too much hassle (as I encountered with log4j and the right one log4j.properties file).

ps-aux
  • 11,627
  • 25
  • 81
  • 128
  • possible duplicate of [Getting the name of the current executing method](http://stackoverflow.com/questions/442747/getting-the-name-of-the-current-executing-method) – Jason C Aug 12 '13 at 17:27
  • 1
    How can this be related to that thread as using `StackTraceElement` or any similar manual way of finding out the method name is exactly what I explicitly stated I am not interested in (as I know about this option)? – ps-aux Aug 12 '13 at 17:47
  • Not sure I understand where your attitude is coming from (plus, there is a perfectly reasonable solution there). Anyways, check out SLF4J (http://stackoverflow.com/questions/2915150/log4j-support-in-android). – Jason C Aug 12 '13 at 17:52
  • Ok. If this question can be can be closed with "No there is no easy-peasy way to have what you want and you need to use and spend time configuring slf4j, log4j or use own logger with StackTraceElement" then so be it. Then this discussion is absolutely waste of time and dtb space. – ps-aux Aug 12 '13 at 17:57
  • SLF4J has an Android package (read the previous link) -- you will find many recommendations for it in the Android programming circle, and it is straightforward to set up. If you refuse to use established logging facilities, but also refuse to implement the (relatively simple) feature yourself, that doesn't seem to leave you with many alternatives. You'll have to do one or the other, you can't escape having to do work here. :) – Jason C Aug 12 '13 at 17:59

0 Answers0