From b291196092e3ba1e54a48615f3694c661b9433e4 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Tue, 06 Apr 2021 12:30:25 +0000
Subject: [PATCH] Logging-Einstellungen

---
 publish/logging.properties                    |   72 ++++++++++++++++++++++++++++++++++++
 src/de/uhilger/mediaz/api/StorageHandler.java |   10 ++--
 src/de/uhilger/mediaz/store/FileStorage.java  |   12 +++--
 src/de/uhilger/mediaz/App.java                |    2 
 publish/start                                 |    3 +
 www/ui/js/app.js                              |    6 +-
 src/de/uhilger/mediaz/api/FileHandler.java    |    2 
 7 files changed, 92 insertions(+), 15 deletions(-)

diff --git a/publish/logging.properties b/publish/logging.properties
new file mode 100644
index 0000000..f3d9883
--- /dev/null
+++ b/publish/logging.properties
@@ -0,0 +1,72 @@
+############################################################
+#      Default Logging Configuration File
+#
+# You can use a different file by specifying a filename
+# with the java.util.logging.config.file system property.  
+# For example java -Djava.util.logging.config.file=myfile
+############################################################
+
+############################################################
+#  	Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler 
+# classes.  These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the INFO and above levels.
+# handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+# handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers.  For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level= FINEST
+# .level = NONE
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = %h/mediaz-%u.log
+# java.util.logging.FileHandler.pattern = /media/extmirror/tomcat747/logs/tv_%u.log
+# java.util.logging.FileHandler.pattern = ${catalina.base}/logs/file-cms_%u.log
+# java.util.logging.FileHandler.limit = 50000
+# java.util.logging.FileHandler.count = 1
+# java.util.logging.FileHandler.count = 2
+# java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+# java.util.logging.FileHandler.level = FINER
+
+# Limit the message that are printed on the console to INFO and above.
+# java.util.logging.ConsoleHandler.level = INFO
+# java.util.logging.ConsoleHandler.level = FINER
+# java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+# Example to customize the SimpleFormatter output format 
+# to print one-line log message like this:
+#     <level>: <log message> [<date/time>]
+#
+# java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+
+# For example, set the com.xyz.foo logger to only log SEVERE
+# messages:
+# com.xyz.foo.level = SEVERE
+# de.uhilger.filecms.handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+# de.uhilger.filecms.level = FINEST
+# de.uhilger.wbx.handlers = java.util.logging.ConsoleHandler
+# de.uhilger.wbx.level = FINEST
+de.uhilger.mediaz.handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+de.uhilger.mediaz.level = FINEST
diff --git a/publish/start b/publish/start
new file mode 100755
index 0000000..93263b1
--- /dev/null
+++ b/publish/start
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+java  -Djava.util.logging.config.file=logging.properties -jar mediaz.jar port=9090 ctx=/mz www-data=./www conf=conf
\ No newline at end of file
diff --git a/src/de/uhilger/mediaz/App.java b/src/de/uhilger/mediaz/App.java
index 351bb27..66d3fab 100644
--- a/src/de/uhilger/mediaz/App.java
+++ b/src/de/uhilger/mediaz/App.java
@@ -55,7 +55,7 @@
    */
   public static void main(String[] args) throws ClassNotFoundException {
     rb = ResourceBundle.getBundle(RB_NAME);
-    logger.info(new File(".").getAbsolutePath());
+    logger.fine(new File(".").getAbsolutePath());
     
     initParams = new HashMap();
     for (String arg : args) {
diff --git a/src/de/uhilger/mediaz/api/FileHandler.java b/src/de/uhilger/mediaz/api/FileHandler.java
index ab20120..5c3cc6b 100644
--- a/src/de/uhilger/mediaz/api/FileHandler.java
+++ b/src/de/uhilger/mediaz/api/FileHandler.java
@@ -133,7 +133,7 @@
   protected String getFileName(HttpExchange e) {
     String ctxPath = e.getHttpContext().getPath();
     String uriPath = e.getRequestURI().getPath();
-    logger.info(uriPath);
+    logger.fine(uriPath);
     return uriPath.substring(ctxPath.length());
   }
   
diff --git a/src/de/uhilger/mediaz/api/StorageHandler.java b/src/de/uhilger/mediaz/api/StorageHandler.java
index e4bf00d..72787d2 100644
--- a/src/de/uhilger/mediaz/api/StorageHandler.java
+++ b/src/de/uhilger/mediaz/api/StorageHandler.java
@@ -120,7 +120,7 @@
         }
         break;
     }
-    logger.info(response);
+    logger.fine(response);
     e.sendResponseHeaders(code, response.length());
     OutputStream os = e.getResponseBody();
     os.write(response.getBytes());
@@ -143,13 +143,13 @@
     String filename = ""; 
     FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF)));
     Gson gson = new Gson();
-    logger.log(Level.INFO, "type: {0}", type);
+    logger.log(Level.FINE, "type: {0}", type);
     Object o = gson.fromJson(body, fs.typeFromName(type).getType());
     if(o instanceof Entity) {
       Object antwortObjekt = fs.write((Entity) o, overwrite);
       if(antwortObjekt instanceof File) {
         File file = (File) antwortObjekt;
-        logger.log(Level.INFO, "Datei {0} geschrieben.", file.getAbsolutePath());
+        logger.log(Level.FINE, "Datei {0} geschrieben.", file.getAbsolutePath());
         filename = file.getName();
         return type + FileHandler.STR_BLANK + filename;
       }
@@ -178,7 +178,7 @@
     FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF)));
     if(path.endsWith(App.getRs(RB_SLASH))) {
       String type = elems[elems.length - 1];
-      logger.info(type);
+      logger.fine(type);
       List list = fs.list(type);
       return jsonWithEnclosingType(list);
     } else {
@@ -210,7 +210,7 @@
     }
     r.close();
     String json = sb.toString();
-    logger.log(Level.INFO, "json: {0}", json);
+    logger.log(Level.FINE, "json: {0}", json);
     return json;
   }
 }
diff --git a/src/de/uhilger/mediaz/store/FileStorage.java b/src/de/uhilger/mediaz/store/FileStorage.java
index bf06140..524e4d2 100644
--- a/src/de/uhilger/mediaz/store/FileStorage.java
+++ b/src/de/uhilger/mediaz/store/FileStorage.java
@@ -148,12 +148,14 @@
   public List<String> list(String typ) {
     File base = new File(fileBase);
     File dir = new File(base, typ);
-    File[] files = dir.listFiles();
     List<String> list = new ArrayList();
-    for(File file : files) {
-      //NamedItem n = new NamedItem();
-      //n.setLabel(file.getName());
-      list.add(file.getName());
+    File[] files = dir.listFiles();
+    if(files != null) {
+      for(File file : files) {
+        //NamedItem n = new NamedItem();
+        //n.setLabel(file.getName());
+        list.add(file.getName());
+      }
     }
     return list;
   }
diff --git a/www/ui/js/app.js b/www/ui/js/app.js
index 7585753..d7f6358 100644
--- a/www/ui/js/app.js
+++ b/www/ui/js/app.js
@@ -60,11 +60,11 @@
             // hier die Antwort verarbeiten
           });
         }
-        document.querySelector(".zentraler-inhalt").innerHTML = '';
+        //document.querySelector(".zentraler-inhalt").innerHTML = '';
         self.ablageort_liste();
       });
       self.addEvtListener('#cancel-btn', 'click', function () {
-        document.querySelector(".zentraler-inhalt").innerHTML = '';
+        //document.querySelector(".zentraler-inhalt").innerHTML = '';
         self.ablageort_liste();
       });
       self.addEvtListener('#loeschen-btn', 'click', function() {
@@ -76,7 +76,7 @@
             self.http_delete('../api/store/Ablageort/' + aoname, '', function (responseText) {
               // hier die Antwort verarbeiten
               self.dialog_schliessen();
-              document.querySelector(".zentraler-inhalt").innerHTML = '';
+              //document.querySelector(".zentraler-inhalt").innerHTML = '';
               self.ablageort_liste();
             });
           });

--
Gitblit v1.9.3