Skip to content

Commit

Permalink
Merge pull request #5267 from rdebusscher/FISH-1415
Browse files Browse the repository at this point in the history
FISH-1415: Write updated log information all at once to logging.properties file.
  • Loading branch information
Rudy De Busscher authored May 30, 2021
2 parents 0be915e + a05021c commit 24d1907
Showing 1 changed file with 32 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* holder.
*/

// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates]

/*
* InstanceHandler.java
Expand All @@ -48,25 +48,25 @@
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author anilam
*/
package org.glassfish.admingui.common.handlers;

import com.sun.jsftemplating.annotation.Handler;
import com.sun.jsftemplating.annotation.HandlerInput;
import com.sun.jsftemplating.annotation.HandlerOutput;
import com.sun.jsftemplating.layout.descriptors.handler.HandlerContext;
import org.glassfish.admingui.common.util.GuiUtil;
import org.glassfish.admingui.common.util.RestUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import org.glassfish.admingui.common.util.GuiUtil;
import org.glassfish.admingui.common.util.RestUtil;


/**
*
* @author anilam
*/
public class LoggingHandlers {

/** Creates a new instance of InstanceHandler */
Expand Down Expand Up @@ -195,35 +195,39 @@ public static void deleteLoggers(List<Map<String, Object>> allRows, String confi
@HandlerInput(name = "attrs", type = Map.class, required=true),
@HandlerInput(name = "config", type = String.class, required=true)
})

public static void saveLoggingAttributes(HandlerContext handlerCtx) {
Map<String,Object> attrs = (Map<String,Object>) handlerCtx.getInputValue("attrs");
String config = (String)handlerCtx.getInputValue("config");
Map<String, Object> props = new HashMap();
try{
Map<String, Object> props = new HashMap<>();
try {
StringBuilder data = new StringBuilder();
for (Map.Entry<String, Object> e : attrs.entrySet()) {
String key=e.getKey();
if ((key.equals("com.sun.enterprise.server.logging.SyslogHandler.useSystemLogging")||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.logtoFile") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.logtoConsole") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.multiLineMode") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.rotationOnDateChange" ) ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.compressOnRotation") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.logStandardStreams") ||
key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.logtoFile") ||
key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationOnDateChange") ||
key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.compressOnRotation"))
String key = e.getKey();
if ((key.equals("com.sun.enterprise.server.logging.SyslogHandler.useSystemLogging") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.logtoFile") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.logtoConsole") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.multiLineMode") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.rotationOnDateChange") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.compressOnRotation") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.logStandardStreams") ||
key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.logtoFile") ||
key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationOnDateChange") ||
key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.compressOnRotation"))
&& (e.getValue() == null)) {
attrs.put(key, "false");
}
props.put("id", key + "='" + attrs.get(key) + "'");
props.put("target", config);
RestUtil.restRequest((String)GuiUtil.getSessionValue("REST_URL") + "/set-log-attributes",
props, "POST", null, false, true);
if (data.length() > 0) {
data.append(":");
}
data.append(key).append("='").append(attrs.get(key)).append("'");
}
}catch (Exception ex){
props.put("id", data.toString());
props.put("target", config);
RestUtil.restRequest((String) GuiUtil.getSessionValue("REST_URL") + "/set-log-attributes",
props, "POST", null, false, true);
} catch (Exception ex) {
GuiUtil.handleException(handlerCtx, ex);
if (GuiUtil.getLogger().isLoggable(Level.FINE)){
if (GuiUtil.getLogger().isLoggable(Level.FINE)) {
ex.printStackTrace();
}
}
Expand Down

0 comments on commit 24d1907

Please sign in to comment.