10-Marble
June 10, 2014
Question
Log4j not writing to file
- June 10, 2014
- 2 replies
- 2273 views
OK, I need a forehead slap, I'm sure. Does running a publish scheduler only allow writing to the background method server log? I was sure we had been using log4j with an external log file but apparently it hasn't been running. Manually using a java logger definitely only goes to the BGMS log file. Am I going crazy here? I was thinking we could specify multiple loggers (for applications) to write to multiple files, but maybe I'm just crazy......
When I try it now, even the windchill shell version isn't writing to the log file. Which it did before. At least that I remember. It's reading the log4j properties and seems to be initializing fine. Log file is created/locked as necessary.
Can anyone lend help in the palm to forehead moment I appear to be needing?
WC 10.1 M020
Thank you,
Brian Krieger
[75th]
Logger class:
public class Logger4j {
private static boolean isInitialized = false;
protected Logger4j() {}
public static Logger getLogger(Class class1) {
if(!isInitialized) {
PropertyConfigurator.configure(PropertyHandler.getPath("LOG4J_PROPERTY_FILE"));
isInitialized = true;
}
Logger logger = Logger.getLogger(class1);
return logger;
}
}
Test class just to log:
import na.paccar.engineering.efolders.util.Logger4j;
import na.paccar.engineering.efolders.util.StartScriptLogger;
import org.apache.log4j.Logger;
public class LogTest {
public static Logger logger = Logger4j.getLogger(LogTest.class);
public static java.util.logging.Logger manualLogger = StartScriptLogger.getStartUpLogger();
public static void main(String[] args){
logger.debug("Message Thrown");
System.out.println("System out message");
manualLogger.info("Info Message Manual Logger");
}
}
Yields the following from a windchill shell:
[cid:image002.png@01CF848D.36795450]
When I try it now, even the windchill shell version isn't writing to the log file. Which it did before. At least that I remember. It's reading the log4j properties and seems to be initializing fine. Log file is created/locked as necessary.
Can anyone lend help in the palm to forehead moment I appear to be needing?
WC 10.1 M020
Thank you,
Brian Krieger
[75th]
Logger class:
public class Logger4j {
private static boolean isInitialized = false;
protected Logger4j() {}
public static Logger getLogger(Class class1) {
if(!isInitialized) {
PropertyConfigurator.configure(PropertyHandler.getPath("LOG4J_PROPERTY_FILE"));
isInitialized = true;
}
Logger logger = Logger.getLogger(class1);
return logger;
}
}
Test class just to log:
import na.paccar.engineering.efolders.util.Logger4j;
import na.paccar.engineering.efolders.util.StartScriptLogger;
import org.apache.log4j.Logger;
public class LogTest {
public static Logger logger = Logger4j.getLogger(LogTest.class);
public static java.util.logging.Logger manualLogger = StartScriptLogger.getStartUpLogger();
public static void main(String[] args){
logger.debug("Message Thrown");
System.out.println("System out message");
manualLogger.info("Info Message Manual Logger");
}
}
Yields the following from a windchill shell:
[cid:image002.png@01CF848D.36795450]

