You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2006/02/01 01:43:53 UTC

DO NOT REPLY [Bug 38468] New: - Patch for HTMLLayout.java to allow the user of the logger to turn the html header/footer off if needed.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38468>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38468

           Summary: Patch for HTMLLayout.java to allow the user of the
                    logger to turn the html header/footer off if needed.
           Product: Log4j
           Version: unspecified
          Platform: All
        OS/Version: other
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Other
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: apache@personal.fishh2o.com


Patch for HTMLLayout.java to allow the user of the logger to turn the html header/footer off if needed.

I'm using log4j to output some html but I'm doing this within an existing webpage.  Therefore, I don't 
need/want the html header/footer that the logger normally prints out.

Added the member var shouldWriteHtmlHeaderAndFooter and the appropriate if statements to make 
the desired effect.  Also added an assessor and setter for shouldWriteHtmlHeaderAndFooter.


Thanx for the awesome logging lib.



Index: HTMLLayout.java
===============================================================
====
RCS file: /home/cvspublic/logging-log4j/src/java/org/apache/log4j/html/HTMLLayout.java,v
retrieving revision 1.7
diff -u -r1.7 HTMLLayout.java
--- HTMLLayout.java	22 May 2005 07:56:22 -0000	1.7
+++ HTMLLayout.java	3 Oct 2005 20:42:58 -0000
@@ -66,6 +66,7 @@
   private FormattingInfo[] patternFields;
   private String timezone;
   private String title = "Log4J Log Messages";
+  private boolean shouldWriteHtmlHeaderAndFooter = true;
 
   private boolean internalCSS = false;
   private String url2ExternalCSS = "http://logging.apache.org/log4j/docs/css/eventTable-1.0.css";
@@ -109,6 +110,16 @@
   public String getConversionPattern() {
     return pattern;
   }
+�
+  public boolean shouldWriteHtmlHeaderAndFooter()
+  {
+	return shouldWriteHtmlHeaderAndFooter;
+  }
+�
+  public void setShouldWriteHtmlHeaderAndFooter(boolean shouldWriteHtmlHeaderAndFooter)
+  {
+	this.shouldWriteHtmlHeaderAndFooter = shouldWriteHtmlHeaderAndFooter;
+  }
 
   /**
    * Does not do anything as options become effective
@@ -236,28 +247,31 @@
    */
   public String getHeader() {
     StringBuffer sbuf = new StringBuffer();
-    sbuf.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"");
-    sbuf.append(" \"http://www.w3.org/TR/html4/loose.dtd\">");
-    sbuf.append(Layout.LINE_SEP);
-    sbuf.append("<html>");
-    sbuf.append(Layout.LINE_SEP);
-    sbuf.append("<head>");
-    sbuf.append(Layout.LINE_SEP);
-    sbuf.append("<title>" + title + "</title>");
-    sbuf.append(Layout.LINE_SEP);
-    if(internalCSS) {
-      getInternalCSS(sbuf);
-    } else {
-      sbuf.append("<LINK REL=StyleSheet HREF=\""+url2ExternalCSS+"\" TITLE=\"Basic\">");
-    }
-    sbuf.append(Layout.LINE_SEP);
-    sbuf.append("</head>");
-    sbuf.append(Layout.LINE_SEP);
-    sbuf.append("<body>");
-    sbuf.append(Layout.LINE_SEP);
-���
-    sbuf.append("<hr size=\"1\" noshade>");
-    sbuf.append(Layout.LINE_SEP);
+	 if(shouldWriteHtmlHeaderAndFooter)
+	 {
+		 sbuf.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"");
+		 sbuf.append(" \"http://www.w3.org/TR/html4/loose.dtd\">");
+		 sbuf.append(Layout.LINE_SEP);
+		 sbuf.append("<html>");
+		 sbuf.append(Layout.LINE_SEP);
+		 sbuf.append("<head>");
+		 sbuf.append(Layout.LINE_SEP);
+		 sbuf.append("<title>" + title + "</title>");
+		 sbuf.append(Layout.LINE_SEP);
+		 if(internalCSS) {
+			getInternalCSS(sbuf);
+		 } else {
+			sbuf.append("<LINK REL=StyleSheet HREF=\""+url2ExternalCSS+"\" TITLE=\"Basic\">");
+		 }
+		 sbuf.append(Layout.LINE_SEP);
+		 sbuf.append("</head>");
+		 sbuf.append(Layout.LINE_SEP);
+		 sbuf.append("<body>");
+		 sbuf.append(Layout.LINE_SEP);
+		
+		 sbuf.append("<hr size=\"1\" noshade>");
+		 sbuf.append(Layout.LINE_SEP);
+	 }
 ���
     sbuf.append("Log session start time " + new java.util.Date() + "<br>");
     sbuf.append(Layout.LINE_SEP);
@@ -290,9 +304,12 @@
   public String getFooter() {
     StringBuffer sbuf = new StringBuffer();
     sbuf.append("</table>" + Layout.LINE_SEP);
-    sbuf.append("<br>" + Layout.LINE_SEP);
-    sbuf.append("</body></html>");
-    return sbuf.toString();
+	 if(shouldWriteHtmlHeaderAndFooter)
+	 {
+		sbuf.append("<br>" + Layout.LINE_SEP);
+		sbuf.append("</body></html>");
+    }
+	 return sbuf.toString();
   }
 
   /**

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 38468] - Patch for HTMLLayout.java to allow the user of the logger to turn the html header/footer off if needed.

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38468>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38468





------- Additional Comments From apache@personal.fishh2o.com  2006-02-01 05:01 -------
Maybe bodyOnly is good and then also add a way to turn off the body tag.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 38468] - Patch for HTMLLayout.java to allow the user of the logger to turn the html header/footer off if needed.

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38468>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38468





------- Additional Comments From lilianne_blaze@tlen.pl  2007-01-06 12:40 -------
I think it would be more flexible with three properties, "bodyOnly" as in above
comments - personally I think "dataOnly" name would be better, and
"generateHeader" / "generateFooter" to control both parts independently.
Plus, maybe add "header" / "footer" properties to override default header/footer
text?
I don't see the point (though I have nothing against it as long as default vaule
 is reasonable - false) of providing an option to skip header/footer while still
generating "<body>" / "</body>" tags. If really needed, it would be possible
with above properties simply as: header="<body>", footer="</body>".

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 38468] - Patch for HTMLLayout.java to allow the user of the logger to turn the html header/footer off if needed.

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38468>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38468


carnold@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX




------- Additional Comments From carnold@apache.org  2007-08-22 19:05 -------
Can be accomplished using XSLTAppender in the extras companion which is hugely configurable.  Marking 
as won't fix.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 38468] - Patch for HTMLLayout.java to allow the user of the logger to turn the html header/footer off if needed.

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38468>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38468





------- Additional Comments From carnold@apache.org  2006-02-01 04:52 -------
Good idea, but the name is awkward.  I thought bodyOnly might be better until I saw that you had the 
body element as part of the header.  Maybe innerOnly?  Any other suggestions?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org