KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cmsinstaller > Logger


1 package org.infoglue.cmsinstaller;
2
3 /* ===============================================================================
4  *
5  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
6  *
7  * ===============================================================================
8  *
9  * Copyright (C)
10  *
11  * This program is free software; you can redistribute it and/or modify it under
12  * the terms of the GNU General Public License version 2, as published by the
13  * Free Software Foundation. See the file LICENSE.html for more information.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along with
20  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
21  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
22  *
23  * ===============================================================================
24  */

25  
26  import java.io.*;
27  
28  public class Logger
29  {
30     private static PrintWriter pw = null;
31     
32     private static void initializePrintWriter() throws Exception JavaDoc
33     {
34         pw = new PrintWriter(new FileOutputStream("install.log"));
35         
36     }
37     
38     public static void logInfo(String JavaDoc message)
39     {
40         System.out.println(message);
41         
42         try
43         {
44             if(pw == null)
45                 initializePrintWriter();
46     
47             pw.println(message);
48             pw.flush();
49         }
50         catch(Exception JavaDoc e)
51         {
52             e.printStackTrace();
53         }
54     }
55     
56     
57     public void finalize()
58     {
59         System.out.println("Running finalize...");
60         try
61         {
62             pw.flush();
63             pw.close();
64         }
65         catch(Exception JavaDoc e){e.printStackTrace();}
66     }
67  }
Popular Tags