# log4testng will log
log4testng.debug=true
# All Logger will log DEBUG level and above
log4testng.rootLogger=DEBUG
# All Logger in packages below org.testng will log WARN level and above
log4testng.logger.org.testng=WARN
In your source files you will typically instantiate and use loggers this ways:
import org.testng.log4testng.Logger;
class ThisClass {
private static final Logger LOGGER = Logger.getLogger(ThisClass.class);
…
LOGGER.debug("entering myMethod()");
…
LOGGER.warn("unknown file: " + filename);
….
Claude
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=33472&messageID=64935#64935
On Jun 5, 2006, at 11:54 PM, Claude Quezel wrote:
>
> TestNG now support logging via a custom logging framework similar
> to Log4j (http://logging.apache.org/log4j). To enable logging, add
> a file named "log4testng.properties" to your classpath. The logging
> levels are TRACE, DEBUG, INFO, WARN, ERROR and FATAL. The property
> file contains lines in the following format:
>
> # log4testng will log
> log4testng.debug=true
>
> # All Logger will log DEBUG level and above
> log4testng.rootLogger=DEBUG
>
> # All Logger in packages below org.testng will log WARN level and
> above
> log4testng.logger.org.testng=WARN
>
> In your source files you will typically instantiate and use loggers
> this ways:
>
> import org.testng.log4testng.Logger;
>
> class ThisClass {
> private static final Logger LOGGER = Logger.getLogger
> (ThisClass.class);
>
> …
> LOGGER.debug("entering myMethod()");
> …
> LOGGER.warn("unknown file: " + filename);
> ….
I agree but one of the goals of TestNG (from what I read) is to have a
stand-alone JAR file. The API is designed to be replaced by log4j. I
don't think packaging one of the most common JAR file (log4j) with
testng is a wise choice. So I opted for the other solution. I would
gladly replace it if design goal are changed.
Claude
Cheers,
Brett
--
Apache Maven - http://maven.apache.org
"Better Builds with Maven" book - http://library.mergere.com/
The verbosity setting is an all or nothing setting (not very useful in
some/most situation). For example, TestNG now generates a warning when
parsing fails when scanning for JavaDoc annotations in files that
contain JDK5+ features. What can I do to silence it^
Hani Suleiman wrote:
> Most users should never need to see a single message from testng,
Hani Suleiman wrote:
Typically logging is rarely for users. It is for developpers (sometimes
helping users) to help locate bugs and identify problems.
> the only usefulness of that is to show bugs, which should get fewer and fewer
> over time!
I slightly disagree here. Logging is usefull for many things (tracing
to help debugging, profilling (using timestamp, ...). Logging is barely
used in testng (maybe because of unflexible support). Most logging
statement are commented out (see all those ppp) maybe because there was
no way to do it dynamically!
Claude
Open source based consulting work centered around dojo/tapestry/tacos/hivemind.
Claude
TestNG now support logging via a custom logging framework similar to Log4j ( http://logging.apache.org/log4j). To enable logging, add a file named "log4testng.properties" to your classpath. The logging levels are TRACE, DEBUG, INFO, WARN, ERROR and FATAL. The property file contains lines in the following format:
I am a little confused by why this would be needed. If we would need such thing, most probably we
would have used the logging from 1.4 which is the minimal version TestNG supports.
br,
./alex
--
.w( the_mindstorm )p.
Cedric, I'm a bit confused here. You say you are skeptical that this is
useful yet there are 163 definitions of the static ppp method (which is
a logging method) in testng. For example:
public static void ppp(String s) {
System.out.println("[SuiteRunner] " + s);
}
private static void ppp(String s) {
if (false) {
System.out.println("[ThreadPoolSizeTest] " + s);
}
There are 387 occurence of ppp (most of them in tests though).
// for (Method m : result) {
// ppp(" METHOD FOUND: " + m);
// }
Some of them commented out. So basically, I think logging is already in
used and usefull in testngl.
Claude
As you noticed, and to make it clear to others, there is no external
library. This is just one very simple class (see
org.testng.logfortestng.Logger) to provide an alternative to all these
ppp calls. Again the target audience for logging is for developpers.
Logging statements typically display class names and method names that
are unknown to users.
Claude
>
>
> Cédric Beust ♔ wrote:
>> I am still very skeptical that this is useful at all, but well,
>> it's a
>> fairly limited change, so we can leave it in...
>
> Cedric, I'm a bit confused here. You say you are skeptical that
> this is
> useful yet there are 163 definitions of the static ppp method
> (which is
> a logging method) in testng. For example:
>
If you're a developer, then you can add your own private logging for
a particular class just to help you debug (though of course, cedric
is being lazy and should use a debugger without silly printlns)
The point being that there's no real reason for a framework like this
to log. If you're a developer, you can add in your own mechanism to
the particular bit of code you're working on (hell, you can even use
log4j, then comment out all the log.debugs!)
Hani,
I'm running testng 4.7 on my company's main projet. TestNG never
returns. Can you help me?
Claude
hah, enable debug!
Oh wait...
Funnily enough in this case debug wouldn't be as useful as a thread
dump, if it's not returning ;)
Hani,
I'm sure Cedic knows the difference between logging and debugging and
uses a debugger like all developers do when he feels it is the right
tool. He uses logging when he feels that is the right tool.
some people (log4j users) find logging usefull. If you don't like using
logging, nothing forces you. For those who do, then there is a
re-usable way to do it in testng configurable without having to modify
code. I don't think TestNG is difefrent from any other software
products when it come to logging.
Claude