Skip to content

Commit

Permalink
Change application log level to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboyan committed Jan 9, 2024
1 parent 51eb61a commit bfaf1b7
Showing 1 changed file with 46 additions and 43 deletions.
89 changes: 46 additions & 43 deletions grace-boot/src/main/groovy/grails/boot/Grails.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,50 +421,53 @@ protected void configureDirectoryWatcher(DirectoryWatcher directoryWatcher, Stri

protected void printRunStatus(ConfigurableApplicationContext applicationContext) {
try {
GrailsApplication app = applicationContext.getBean(GrailsApplication.APPLICATION_ID, GrailsApplication.class);
String protocol = app.getConfig().getProperty("server.ssl.key-store") != null ? "https" : "http";
if (applicationContext.getParent() != null) {
applicationContext.publishEvent(
new ApplicationPreparedEvent(
this,
new String[0],
(ConfigurableApplicationContext) applicationContext.getParent())
);
}
String contextPath = app.getConfig().getProperty("server.servlet.context-path", "");
String hostName = app.getConfig().getProperty("server.address", "localhost");
int port = 8080;
if (applicationContext instanceof WebServerApplicationContext) {
port = ((WebServerApplicationContext) applicationContext).getWebServer().getPort();
}
String hostAddress = "localhost";
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
}
catch (UnknownHostException e) {
getApplicationLog().warn("The host name could not be determined, using `localhost` as fallback");
Log log = getApplicationLog();
if (log.isDebugEnabled()) {
GrailsApplication app = applicationContext.getBean(GrailsApplication.APPLICATION_ID, GrailsApplication.class);
String protocol = app.getConfig().getProperty("server.ssl.key-store") != null ? "https" : "http";
if (applicationContext.getParent() != null) {
applicationContext.publishEvent(
new ApplicationPreparedEvent(
this,
new String[0],
(ConfigurableApplicationContext) applicationContext.getParent())
);
}
String contextPath = app.getConfig().getProperty("server.servlet.context-path", "");
String hostName = app.getConfig().getProperty("server.address", "localhost");
int port = 8080;
if (applicationContext instanceof WebServerApplicationContext) {
port = ((WebServerApplicationContext) applicationContext).getWebServer().getPort();
}
String hostAddress = "localhost";
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
}
catch (UnknownHostException e) {
log.warn("The host name could not be determined, using `localhost` as fallback");
}
StringBuilder sb = new StringBuilder();
sb.append("%n----------------------------------------------------------------------------------------------");
sb.append("%n Application: %s");
sb.append("%n Version: %s");
sb.append("%n Environment: %s");
sb.append("%n Local: %s://%s:%s%s");
sb.append("%n External: %s://%s:%s%s");
sb.append("%n----------------------------------------------------------------------------------------------");
sb.append("%n");
log.debug(String.format(sb.toString(),
app.getConfig().getProperty("info.app.name"),
app.getConfig().getProperty("info.app.version"),
Environment.getCurrent().getName(),
protocol,
hostName,
port,
contextPath,
protocol,
hostAddress,
port,
contextPath));
}
StringBuilder sb = new StringBuilder();
sb.append("%n----------------------------------------------------------------------------------------------");
sb.append("%n Application: %s");
sb.append("%n Version: %s");
sb.append("%n Environment: %s");
sb.append("%n Local: %s://%s:%s%s");
sb.append("%n External: %s://%s:%s%s");
sb.append("%n----------------------------------------------------------------------------------------------");
sb.append("%n");
getApplicationLog().info(String.format(sb.toString(),
app.getConfig().getProperty("info.app.name"),
app.getConfig().getProperty("info.app.version"),
Environment.getCurrent().getName(),
protocol,
hostName,
port,
contextPath,
protocol,
hostAddress,
port,
contextPath));
}
catch (Exception ignored) {
}
Expand Down

0 comments on commit bfaf1b7

Please sign in to comment.