Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.2k views
in Java FTP by (140 points)
I am writing a program to go out and download data from various continuous GPS station around the world. These connection are generally very poor so I would like to download from more than one station at a time. I would like each station to have it's own log file.

When i use the forum suggested Logger.addAppender("nameOfStation.log"); I get the desired individual log files but each one has the same thing in it from all the other stations.

So my question is; How do give each thread it's own unique thread safe Logger so that each station log has only the information for itself???

Thanks in advance!
-abel

5 Answers

0 votes
by (162k points)
Currently, you can't do this. It would be a useful enhancement that we'll take a look at.
0 votes
by (300 points)
We're having similar problem... with multiple threads. Would like each thread, with its own FTP instance to log to its own file; not mixed together. It appears that the Logger is static?
Dave
0 votes
by (162k points)
Sounds like it is time we found a solution ... we'll take a look. I'm not sure about the feasibility of each thread logging to its own file, at least in the very short term.

Is appending the thread name to the logger name of any use to you? At least that way you can easily distinguish the different threads in the output, and grep out what you need.
0 votes
by (300 points)
The java program in question keeps a single VM (java 1.5) up and running, and each thread is dedicated to a specific transmission method (e.g. FTP Send, HTTPS POST, etc.) and we have a configurable number of threads per type. For each data file sent, we actually start/stop sessions on different threads to different ftp sites, etc; logging is done by each EDT FTP thread, so each may start FileAppenders to a Logger within milli-seconds of each other. We sometimes get log info/debug from other threads in the wrong "temp" log... We send thousands of files to our customers every day and unfortunately must have some evidence that the file was properly transmitted to them.

We have tried the following in the code... i.e. using a unique "session-id" concept:

// Create an EDT debug logger to append to the regular log file
if (myLog.getCurrentSessionID() > -1) {
ftpLogger = com.enterprisedt.
util.debug.Logger.getLogger(this.getClass().getName() +
myLog.getCurrentSessionID());
} else {
ftpLogger = com.enterprisedt.
util.debug.Logger.getLogger(this.getClass());
}
ftpLogger.setLevel(Level.DEBUG);
Appender logAppender = new FileAppender(myLog.getFullName());
ftpLogger.addAppender(logAppender);

Sample output:
DEBUG [com.enterprisedt.net.ftp.FTPClient] 1 May 2007 06:21:10.94 : Class: com.enterprisedt.net.ftp.ssl.SSLFTPClient
Version: 1.2.8
Build timestamp: 24-May-2006 12:04:20 EST
Java version: 1.5.0_08
CLASSPATH: c:\ASPCORE\thirdparty\jintegra\lib\jintegra.jar;C:\oracle\ora92\jdbc\lib\ojdbc14.jar;C:\Dev Library Jars\ecpcore.jar;c:\ASPCORE\thirdparty\JavaMail\mail.jar;c:\ASPCORE\thirdparty\JavaMail\activation.jar;c:\ASPCORE\THIRDPARTY\ChaseBank\ChaseBank.jar;C:\Dev Library Jars\EDT\edtftpj-pro.jar;C:\Dev Library Jars\EDT\license.jar;c:\ASPCORE\thirdparty\ORO\NetComponents.jar;.;C:\Program Files\Java\jre1.5.0_09\lib\ext\QTJava.zip
OS name: Windows XP
OS arch: x86
OS version: 5.1

INFO [com.enterprisedt.util.license.LicenseProperties] 1 May 2007 06:21:10.94 : Licence expiry date: 31 Dec 2099
INFO [com.enterprisedt.util.license.LicenseProperties] 1 May 2007 06:21:10.94 : Production licence
DEBUG [com.enterprisedt.net.ftp.ssl.SSLFTPClient] 1 May 2007 06:21:10.94 : Setting custom validator to com.enterprisedt.net.ftp.ssl.SSLFTPStandardValidator
INFO [com.ecpower.comm.FTPWrapper85] 1 May 2007 06:21:10.94 : Using FTP protocol Note: The 85 is the session ID used during creation
05/01-06:21:10.85: FTPWrapper(1.2): Making connection
DEBUG [com.enterprisedt.net.ftp.ssl.SSLFTPClient] 1 May 2007 06:21:10.94 : Created explicit FTPS client.
DEBUG [com.enterprisedt.net.ftp.ssl.SSLFTPClient] 1 May 2007 06:21:10.109 : Connecting to /10.10.11.120:21
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 1 May 2007 06:21:10.125 : 220 test.asp.ec-power.com - (L03) For Authorized Use ONLY
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 1 May 2007 06:21:10.125 : DISABLE_CONTROL_SSL_CLOSURE=true
...
Is this what you were suggesting? Note that the INFO and DEBUG statements from the API don't have our session ID 85...
Dave
0 votes
by (162k points)
If you want to try out a version of edtFTPj that can use thread names in logging, email us at support at enterprisedt dot com. We've added a global flag to enable this for all Loggers, and also an instance flag so it can be enabled per Logger.

It simply outputs the thread name prepended to the Logger name, e.g.

DEBUG [main_MyLoggerName] 1 May 2007 11:08:41.220 : My log statement

Categories

...