zlatinb / muwire

MuWire file sharing client for I2P
GNU General Public License v3.0
192 stars 27 forks source link

Where are the log files on linux? #155

Closed ghost closed 2 years ago

ghost commented 2 years ago

I've tried adding a folder to MuWire but it hasn't added it, I want to take a look at the logs to see if it's working on the task or has failed. Where can I find the logs?

I'm using this in my environment

export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-$HOME/.xdg}"

So I've taken a look at ~/.cache/MuWire but there isn't anything.

zlatinb commented 2 years ago

By default logging is disabled, I can help you enable it but I think something else is going on. The MuWire settings directory is in ${XDG_CONFIG_HOME}/MuWire. Inside that folder there will be several files and folders, one of which is called directories. It should contain one file ending in .json for each folder that is shared.

But first, did the folder you added have any files in it? If it didn't, MuWire will not process it. Try adding a folder with some files in it by clicking the Share button or by dragging-and-dropping the folder onto the library. If that doesn't work I'll show you how to turn on logging and we can investigate further.

ghost commented 2 years ago

There are many json files in directories so I guess it's processing it. Please tell me how to enable logging as I can't see any sign that the task is executing in the UI.

zlatinb commented 2 years ago

Ok, enabling logging is a bit complicated, especially on the AUR package. Anyway, this is how you can do it:

  1. Copy this text and save it in your home folder in a file called logging.properties
  2. On line 37 of the file, change MuWire.log to /path/to/log/directory/MuWire.log
  3. At the end of the file add these two lines:
    com.muwire.core.files.level = FINE
    com.muwire.core.files.directories.level = FINE
  4. Find the script that launches MuWire. I'm guessing that would be /usr/bin/muwire or muwire.sh based on the AUR package descriptor
  5. Under the line -DdisableUpdates='true' \ add a line -Djava.util.logging.config.file=/home/<username>/logging.properties \
  6. Restart MuWire. If everything goes well a file called MuWire.log should appear in the path you configured in step 2 above.

Let me know if that works.

ghost commented 2 years ago

There is no file /home/user/.config/MuWire/MuWire.log. This are the files after the changes: /home/user/logging.properties /usr/bin/muwire

Can I place logging.properties in /home/user/.config/MuWire/logging.properties? And can I use $HOME in logging.properties in this line? java.util.logging.FileHandler.pattern = /home/user/.config/MuWire/MuWire.log?

zlatinb commented 2 years ago

The logging.properties file looks correct and the changes to /usr/bin/muwire look correct too. You can place the logging.properties file anywhere you wish as long as in the start script you reference it with -Djava.util.logging.config.file=/path/logging.properties. However you cannot use environment variables inside the logging.properties file itself, it needs to contain absolute paths.

Can you check if MuWire.log appeared in your home directory? Another thing you can try is to launch MuWire from a terminal and see if it prints out anything on stdout or stderr.

I'm going to ask the AUR package maintainer to take a look too. @dbermond can you think of any reason why the logging configuration isn't working?

I need to go afk for a few hours as it's getting late here but I'll check on this issue later.

ghost commented 2 years ago

I hadn't saved the file /usr/bin/muwire. Now I see MuWire.log. What are the available log levels and how can I change it?

zlatinb commented 2 years ago

There are several, MuWire uses only SEVERE, WARNING, INFO and FINE.

If it's processing the shared folders and files there should be entries in MuWire.log already. Are there any?

dbermond commented 2 years ago

@zlatinb It looks like the OP solved the issue, as he has not saved the file.

It's not a good idea to modify /usr/bin/muwire, as this file is tracked by pacman and thus it will be overwritten at each package upgrade. So the user will lose the modification after upgrading the package. As a general rule, files shipped by the package should not modified due to this reason.

Instead, the needed java options can be simply specified at command line when in need to enable logging:

JDK_JAVA_OPTIONS+='-Djava.util.logging.config.file=/path/to/logging.properties' muwire

This works fine for me and MuWire.log is correctly generated at the location specified by the pointed logging.properties.

If you want the logging option to be permanent without the need to specify it at command line every time, you should create a custom script, place it in your PATH and execute it instead of the one shipped by the package.

ghost commented 2 years ago

Yes, the files appear in the log.

What other things can be logged besides com.muwire.core.files.level and com.muwire.core.files.directories.level? In case I need it at another time.

zlatinb commented 2 years ago

The logging levels can be specified per package or class level. There are many packages that contain many classes in MuWire, so it really depends on what kind of functionality you want to troubleshoot. You would need to look in the code for the package and class names (under core/src/main/groovy) or ask me.

zlatinb commented 2 years ago

To set the "global" level for all packages, edit the line that looks like

.level = ...

I recommend you keep the global level at SEVERE or WARNING otherwise you will get too much information and possibly even slow MuWire down.