<ant antfile="../AnotherProject/build.xml" target="mytarget">
Call another target within the same buildfile. It can be used also for imported buildfile.
<antcall target="mytarget">
The complete list of Ant core tasks can be found here.
Tipps & Tricks about Java, Linux and company from my every-day life as developer
<ant antfile="../AnotherProject/build.xml" target="mytarget">
<antcall target="mytarget">
StringBuilder 37708
StringBuffer 95319
String 5389877
C-Like 10690022
MessageFormat 30410260
if (logger.isLoggable(Level.FINEST)) {
logger.finest("log this: "+value);
}try {
// Test with an exception
throw new Exception();
} catch (Throwable e) {
// Log the exception
logger.log(Level.SEVERE, "your message", e);
}public int myMethod(String p1, int p2) {
log.entering(MyClass.class.getName(), "myMethod",
new Object[] { p1, p2 });
if (p2 < 0) {
Exception ex = new IllegalStateException();
log.throwing(this.getClass().getName(), "myMethod", ex);
}
int result = p2 * 2;
log.exiting(MyClass.class.getName(), "myMethod", result);
return result;
}
| log4J | Java Logging |
|---|---|
| log4j.fatal("msg"); | - |
| log4j.error("msg"); | logger.severe("msg"); |
| log4j.warn("msg"); | logger.warning("msg"); |
| log4j.info("msg"); | logger.info("msg"); |
| log4j.debug("msg"); | logger.config("msg"); |
| - | logger.fine("msg"); |
| - | logger.finer("msg"); |
| - | logger.finest("msg"); |
private static final Logger log =
Logger.getLogger(MyClass.class.getPackage().getName());
logging.properties file.$JAVA_HOME/jre/lib/ but you can use a different file by specifying a filename with the java.util.logging.config.file system property (for example java -Djava.util.logging.config.file=/path/to/log.properties).############################################################
# Default Logging Configuration File
############################################################
############################################################
# Global properties
############################################################
# "handlers" specifies a comma separated list of log Handler
# classes. These handlers will be installed during VM startup.
# Note that these classes must be on the system classpath.
# By default we only configure a ConsoleHandler, which will only
# show messages at the INFO and above levels.
handlers= java.util.logging.ConsoleHandler
# To also add the FileHandler, use the following line instead.
#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
# Default global logging level.
# This specifies which kinds of events are logged across
# all loggers. For any given facility this global level
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
.level= INFO
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
# default file output is in user's home directory.
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
# Limit the message that are printed on the console to INFO and above.
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
# For example, set the com.xyz.foo logger to only log SEVERE
# messages:
com.xyz.foo.level = SEVERE
java.util.logging.Formatter and overriding the method format(LogRecord).
String filename = "mylog.log";
PrintStream stream = new PrintStream(filename);
System.setErr(stream);
String logFolderName = "log";
File logFolder = new File(logFolderName);
// Create the log folder if it non already exists
if (!logFolder.exists()) {
logFolder.mkdirs();
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH:mm");
StringBuilder sb = new StringBuilder();
sb.append(logFolderName);
sb.append(System.getProperty("file.separator"));
sb.append("mystderr");
sb.append("_");
sb.append(df.format(new Date()));
sb.append(".log");
PrintStream stream = new PrintStream(sb.toString());
System.setErr(stream);
log/mystderr_2008-02-16_22:09.log