Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Tor logging to DEBUG level at startup #6285

Merged
merged 1 commit into from Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions common/src/main/java/bisq/common/app/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public static void setCustomLogLevel(String pattern, Level logLevel) {
((Logger) LoggerFactory.getLogger(pattern)).setLevel(logLevel);
}

public static String pushCustomLogLevel(String pattern, String logLevel) {
Level oldLevel = ((Logger) LoggerFactory.getLogger(pattern)).getLevel();
((Logger) LoggerFactory.getLogger(pattern)).setLevel(Level.toLevel(logLevel));
return oldLevel == null ? "INFO" : oldLevel.toString();
}

public static void filterByThreadName(String threadName) {
logbackLogger.getLoggerContext().addTurboFilter(new TurboFilter() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import bisq.common.Timer;
import bisq.common.UserThread;
import bisq.common.app.Log;
import bisq.common.proto.network.NetworkProtoResolver;
import bisq.common.util.Utilities;

Expand Down Expand Up @@ -208,6 +209,8 @@ private void restartTor(String errorMessage) {
private void createTorAndHiddenService(int localPort, int servicePort) {
torStartupFuture = executorService.submit(() -> {
try {
// temporarily switch tor to debug logging
String savedLogLevel = Log.pushCustomLogLevel("org.berndpruenster.netlayer", "DEBUG");
// get tor
Tor.setDefault(torMode.getTor());

Expand All @@ -222,6 +225,8 @@ private void createTorAndHiddenService(int localPort, int servicePort) {
"Tor hidden service published after {} ms. Socket={}\n" +
"################################################################",
(new Date().getTime() - ts2), socket); //takes usually 30-40 sec
// tor has started, revert from debug to original log level
Log.pushCustomLogLevel("org.berndpruenster.netlayer", savedLogLevel);
new Thread() {
@Override
public void run() {
Expand Down