3

How can I generate and then find the log file for when I attempt to start a Windows service created through install4j? I specifically want to find the Java exception stack trace if there is one.

Context: I am trying to add a launcher to an install4j project. The launcher is set to create a Windows service from a jar.

Details: When it installs it does install all the necessary files (the jar is included in the install and runs perfectly from the command line), but the generated Windows Service and .exe fail. The .exe closes instantly, and the Service throws a 1067 error if I have the 'fail if an exception in main...' flag set to true. If I set that flag to false I get a message saying that the 'service started and then stopped...' when I attempt to start the service.

The most likely source of an error, the only one I can think of that would cause termination, is a FileNotFoundException from when I try and read my config file. I believe that I could correct my reference to that config file if I could see what the relative path results in, but I have not been able to find the log for when the windows service runs. I've found plenty of resources that appear to show how to get installer log files, even log files from the exe, but none for getting logs from a generated service.

Note: The executable generated by install4j doesnt start question is similar, but that question is asking about an exe, not about a Windows service. (Not to say I didn't try it, but running the .exe with that argument did not create a log file, even an empty one.)

Note about the config file: It's located in the directory 'config' in the same directory as the jar and exe. So, the relative path that the jar uses is "config/config.txt"

Community
  • 1
  • 1
Jeutnarg
  • 1,138
  • 1
  • 16
  • 28

2 Answers2

4

If the exception is in your code, you can set up redirection of stderr on the "Executable info->Redirection" step of the launcher wizard.

To get the native log file of the service, define the environment variable

INSTALL4J_LOG=yes

for all users and restart the service. The log file is named i4jlog... and save to the %TEMP% directory. For the NT AUTHORITY\\LOCAL SERVICE user account that directory is

C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp
Ingo Kegel
  • 46,523
  • 10
  • 71
  • 102
  • I didn't need to use the second portion of your answer, but the Redirection worked like a charm. Accepted. – Jeutnarg Feb 05 '16 at 16:25
0

In Install4j: Go to "Launchers" Click "Redirection" Check Redirect stderr and stdout

Under "Invocation:" make sure your main class is correct.

This works for all install4j installers. Check the Program Files/YourApp/ for the log files.

Common Service Installer Mistakes:

Forget to install the service. Go to Installer: Screens and Actions: Under Installer, I use: Stop a service (for upgrade) Create program group Register Add Item Install a Service

Under Uninstaller: Uninstallation: Stop a service

bhlowe
  • 418
  • 4
  • 8