Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
8.8k views
in Java FTP by (200 points)
I'm testing code using FTP client API product level 1.4.4
So far it has been working well but today I came across the problem of not being able to write log to File Appender.
It works filne for default logging which is StandardOutputAppender but as soon as I switch off to make log go to a file it only allocates the file but does not write out anything to it neither to screen.
Do you have any idea what is going on???
Your answer would be highly appreciated.
Thanks a lot.

7 Answers

0 votes
by (161k points)
Can you please post a small program that illustrates the problem?

I'm testing code using FTP client API product level 1.4.4
So far it has been working well but today I came across the problem of not being able to write log to File Appender.
It works filne for default logging which is StandardOutputAppender but as soon as I switch off to make log go to a file it only allocates the file but does not write out anything to it neither to screen.
Do you have any idea what is going on???
Your answer would be highly appreciated.
Thanks a lot.
0 votes
by (200 points)
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPMessageCollector;
import com.enterprisedt.net.ftp.FTPTransferType;
import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.net.ftp.FTPException;
import com.enterprisedt.util.debug.Logger;
import com.enterprisedt.util.debug.Level;
import com.enterprisedt.util.debug.FileAppender;

private static Logger log;

/**
* Log stream
*/
log = Logger.getLogger(ImageArchiveVDImp.class);

/* get instance of ImageAchiveConfig */

try{
ImageArchiveConfig iac = new ImageArchiveConfig();
iac.populateProperties();

/* set the logger level */

setLogLevel(iac.getLogLevel().charAt(0));

/* make logging go to file */

Logger.addAppender(new FileAppender(fileLogAppender));
log.info("ArchiveImage is beginning to run");
/* set up a FTP session with mainframe */

ftp = new FTPClient(host);
ftp.login(user, password);

private void setLogLevel(char c){
switch (c) {
case 'O':
Logger.setLevel(Level.OFF);
break;
case 'F':
Logger.setLevel(Level.FATAL);
break;
case 'E':
Logger.setLevel(Level.ERROR);
break;
case 'W':
Logger.setLevel(Level.WARN);
break;
case 'I':
Logger.setLevel(Level.INFO);
break;
case 'D':
Logger.setLevel(Level.DEBUG);
break;
case 'A':
Logger.setLevel(Level.ALL);
break;
default:
Logger.setLevel(Level.OFF);
System.out.println("Non existent log level set, no logging");
}
}

Can you please post a small program that illustrates the problem?

I'm testing code using FTP client API product level 1.4.4
So far it has been working well but today I came across the problem of not being able to write log to File Appender.
It works filne for default logging which is StandardOutputAppender but as soon as I switch off to make log go to a file it only allocates the file but does not write out anything to it neither to screen.
Do you have any idea what is going on???
Your answer would be highly appreciated.
Thanks a lot.
[code][/code][/quote]
0 votes
by (161k points)
Thanks, we'll test your code and get back to you ASAP

import com.enterprisedt.net.ftp.FTPClient;
0 votes
by (200 points)
Thanks a lot.
0 votes
by (161k points)
This looks suspicious:

setLogLevel(iac.getLogLevel().charAt(0));

Thanks, we'll test your code and get back to you ASAP

import com.enterprisedt.net.ftp.FTPClient;
0 votes
by
This looks suspicious:

setLogLevel(iac.getLogLevel().charAt(0));

Thanks, we'll test your code and get back to you ASAP

import com.enterprisedt.net.ftp.FTPClient;


I'm attaching the entire code of class doing a major bulk of work.
The line of code above works right it is getting one character for a level of logging from a different class responsible for handling the configuration parameters and subsequently sets it as the current one for this run.
What else I've noticed is the problem only occurs when I set the logging level as my configuration parameter to INFO which i my ultimate goal if I do DEBUG it works though some log.info() statements don't.
If you need my configuration paramenter class source I'll do it too.
Let me know.
Thank you.
/*
* TestImageFtp.java
*
* Created on September 20, 2004, 10:23 AM
*/

package com.abnamro.na.net.viewdir;

/**
*
* @author david.frenkel
*/

import java.util.*;
import java.io.*;
import org.w3c.dom.*;

import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPMessageCollector;
import com.enterprisedt.net.ftp.FTPTransferType;
import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.net.ftp.FTPException;
import com.enterprisedt.util.debug.Logger;
import com.enterprisedt.util.debug.Level;
import com.enterprisedt.util.debug.FileAppender;
import com.enterprisedt.util.debug.StandardOutputAppender;



public class ImageArchiveVDImp implements ImageArchiveVD, Observer{
String host = null;
String user = null;
String password = null;
FTPClient ftp = null;
String fileNameImage = null;
String PDSname = null;
String ddName = null;
String localJCLpath = null;
String localJes2MsgPath = null;
String reportId = null;
String section = null;
String memberName = null;
static int k = 0;
static int totalNumImg = 0;
String remoteFileName = null;
int frequency;
boolean jobRC;
String jobName = null;
String fileLogAppender= null;

/* Mainframe DASD prperties */
String cyl_prim_flat = null;
String cyl_secd_flat = null;
String cyl_prim_pds = null;
String cyl_secd_pds = null;
String num_dir_pds = null;

static final String ITEM_SPACE = " "; //30 blanks
static final String VERSION_SPACE = " "; //14 blanks

private static Logger log;


/** Creates a new instance of TestImageFtp */

public ImageArchiveVDImp() throws Exception{
/* host = "aa2t.net.na.abnamro.com";
frequency = 10000; //10 sec
user = "edfreni";
password = "2004novs";
remoteFileName="tranfile";
localPathText1="C:\\Data\\J2EE\\mobius_ftp\\test\\classes\\com\\abnamro\\na\\net\\viewdir\\trans1.txt";
localPathText2="C:\\Data\\J2EE\\mobius_ftp\\test\\classes\\com\\abnamro\\na\\net\\viewdir\\trans2.txt";
int lindx = localPathText1.lastIndexOf("");
String wrk = localPathText1.substring(lindx+1);
lindx = wrk.lastIndexOf(".");
fileNameText1 = wrk.substring(0,lindx);
lindx = localPathText2.lastIndexOf("");
wrk = localPathText2.substring(lindx+1);
lindx = wrk.lastIndexOf(".");
fileNameText2 = wrk.substring(0,lindx);
System.out.println(fileNameText1 + " " + fileNameText2);
localPathImage1= "C:\\DATA\\J2EE\\mobius_ftp\\test\\classes\\com\\abnamro\\na\\net\\viewdir\\image1.tif";
localPathImage2= "C:\\DATA\\J2EE\\mobius_ftp\\test\\classes\\com\\abnamro\\na\\net\\viewdir\\image2.tif";
localJCLpath = "C:\\DATA\\J2EE\\mobius_ftp\\test\\source\\com\\abnamro\\na\\net\\viewdir\\myfile.txt";
PDSname = "pds";
ddName = "IMAGES";
reportId= "QASXXIMG";
//fileNameImage = "pds(A000000" + k + ")"; //"A" +("000000"+k++)
fileNameImage = "pds(A000000";
fileNameImage2 = "pds(" + fileNameText2 + ")";
localJes2MsgPath = "c:\\DATA\\J2EE\\mobius_ftp\\test\\source\\com\\abnamro\\na\\net\\viewdir\\jobmsg.txt";
System.out.println(fileNameImage + " " + fileNameImage2);
jobName="edfrenix"; */


/**
* Log stream
*/
log = Logger.getLogger(com.abnamro.na.net.viewdir.ImageArchiveVDImp.class);
//System.out.println(getClass().getName());
//Class cl = getClass();
//cl.forName(cl.getName()+".class");
//log = Logger.getLogger(cl.forName(cl.getName()+".class"));

/* get instance of ImageAchiveConfig */

try{

ImageArchiveConfig iac = new ImageArchiveConfig();
iac.populateProperties();

/* get all properties */
host = iac.getHost();
user = iac.getUser();
ddName = iac.getDdName();
password = iac.getPassword();
frequency = iac.getFrequency();
jobName = iac.getJobName();
localJCLpath = iac.getLocalJCLpath();
PDSname = iac.getPDSname();
remoteFileName = iac.getRemoteFileName();
reportId = iac.getReportId();
localJes2MsgPath = iac.getLocalJes2MsgPath();
memberName = iac.getMemberName();
fileLogAppender = iac.getFileLogAppender();

fileNameImage = PDSname + "(" + memberName;

cyl_prim_flat = iac.getCyl_Prim_Flat();
cyl_secd_flat = iac.getCyl_Secd_Flat();
cyl_prim_pds = iac.getCyl_Prim_Pds();
cyl_secd_pds = iac.getCyl_Secd_Pds();
num_dir_pds = iac.getNum_Dir_Pds();

/* set the logger level */

setLogLevel(iac.getLogLevel().charAt(0));

/* make logging go to file */

Logger.addAppender(new FileAppender(fileLogAppender));

log.info("ArchiveImage is beginning to run");
/* set up a FTP session with mainframe */

ftp = new FTPClient(host);
ftp.login(user, password);

/*delete files if they are there */

cleanup();
ftp.setConnectMode(FTPConnectMode.PASV);
setupTransaction();
setupPDS();

} catch (Exception e) {
log.info("can't start application due to " + e.getMessage());
throw new RuntimeException("get the ImageArchive log to investigate");
}
}
private void setLogLevel(char c){
switch (c) { <
0 votes
by (161k points)
Actually, if you can email the code to support at enterprisedt dot com and edit your last post to remove the code that would be good.

I'm attaching the entire code of class doing a major bulk of work.

Categories

...