简体   繁体   中英

How to enable logging for Apache FtpServer

I'm using the Apache FTPServer in my application. it work just fine the only issue; I don't know how to log the operation made on the application side like the downloaded files...

here is my source code

    public static void main(String[] args) throws FtpException {
    PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
    UserManager userManager = userManagerFactory.createUserManager();
    BaseUser user = new BaseUser();
    user.setName("test");
    user.setPassword("123456");
    user.setHomeDirectory("/ftp_data");
    userManager.save(user);

    ListenerFactory listenerFactory = new ListenerFactory();
    listenerFactory.setPort(21);

    FtpServerFactory factory = new FtpServerFactory();
    factory.setUserManager(userManager);
    factory.addListener("default", listenerFactory.createListener());

    FtpServer server = factory.createServer();
    server.start();
}

any Ideas?

Since the Apache FTPServer use Log4j you can configure your log4j.properties files to use it in your project,

Here is how to do it .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM