How to view logs for exceptions? - Advanced Installer Community
sanjaydalvi
Posts: 7
Joined: Tue Sep 10, 2013 3:35 pm

How to view logs for exceptions?

I am new to Advanced Installer and i am trying to implement a java application as a service. My java application binds to port 9050. When i try to start the service, it starts successfully and then stops.

here is my code

Code: Select all

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

public
class Server {
    private final int port;

    public
    Server(int port) {
        this.port = port;
    }

    public static
    void main(String[] args) throws Exception {
        int port;
        if (args.length > 0) {
            port = Integer.parseInt(args[0]);
        }
        else {
            port = 9050;
        }

        new Server(port).run();
    }

    public
    void run() throws Exception {
        // Configure the server.
        EventLoopGroup bossGroup = new NioEventLoopGroup();
        EventLoopGroup workerGroup = new NioEventLoopGroup();
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(bossGroup, workerGroup)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(new Initializer());

            Channel ch = b.bind(port).sync().channel();
            ch.closeFuture().sync();
        }
        finally {
            bossGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();
        }
    }
}


I want the service to continously run on 9050. If this throws any excpetion, where do i check the logs?
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: How to view logs for exceptions?

Hello and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

I'm not sure why you encountered this behavior. In order to find out more information about your service behavior you can take a look on the “Windows event viewer” log where you might see why your service stopped.

Please take a look on our Java service installation article which may be useful to you.

Please let us know if that helped, otherwise give us more details.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
sanjaydalvi
Posts: 7
Joined: Tue Sep 10, 2013 3:35 pm

Re: How to view logs for exceptions?

Hi Dan,
Thanks for the quick reply!!

I have followed the same link "java service installation" to get the example running successfully. But now i am trying to implement the same logic with my code.

“Windows event viewer” logs show 3 events :
1. service entered the running state
2. was successfully sent a start control
3. service entered the stopped state

I think this means the service starts successfully and then stops. I want to keep the service running, just like in the example tutorial. Can i trace the logs for the code so that i can understand what is happening at the run method.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: How to view logs for exceptions?

Hello,

Can you please try to manually install and start your java service and see if the behavior still persist? If so, I'm afraid you should debug your service in order to detect the root cause of this behavior.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”