Java - error implementing logging code
<p>I want to implement OSGI bundle which can write error messages into log file. I have some some errors in the code that I cannot solve. I have commented the code code where Netbeans give me errors.</p>

<p>public class LoggingSystemImpl implements LoggingSystem {</p>

<pre><code>   private final static Calendar calendar = Calendar.getInstance();
   private final static String user = System.getenv("USERNAME").toLowerCase();
   private final static String sMonth = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.ENGLISH);
   private final static int y = calendar.get(Calendar.YEAR);

   // the name of the log file
   //private final String logName = sysDrive + "\\fttb_web - " + sMonth.toLowerCase() + ", " + y + ".log";
   private final String logName = "logger - " + sMonth.toLowerCase() + ", " + y + ".log";

   private static boolean closed;
   private static Log log = null;
   private static BufferedWriter bw = null;
   private static FileOutputStream fos = null;
   private static OutputStreamWriter osw = null;

   public LoggingSystemImpl() {
   }


   public String LoggingSystemUtilization() throws FileNotFoundException{


       return "ok";
   }


   private String Log() throws IOException
{
    fos = new FileOutputStream(logName, true);

    // set encoding to cyrillic (if available)
    if (Charset.isSupported("windows-1251"))
    {
        osw = new OutputStreamWriter(fos, Charset.forName("windows-1251"));
    }
    else { osw = new OutputStreamWriter(fos); }

    bw = new BufferedWriter(osw, 2048); // 2Mb buffer

    return"ok";

}

// intro header for log session
public static synchronized Log getInstance() throws IOException
{
    boolean exc = false;
    try
    {
        if (log == null || closed)
        {
            log = new Log() {};
</code></pre>

<p>error message in Netbeans:  is not abstract and does not override abstract method getPrintStream() in sun.rmi.runtime.Log</p>

<pre><code>            closed = false;
            log.writeln("logged in.");
</code></pre>

<p>error message: cannot find symbol
  symbol:   method writeln(java.lang.String)
  location: variable log of type sun.rmi.runtime.Log</p>

<pre><code>log.nl();
</code></pre>

<p>error message: cannot find symbol
  symbol:   method nl()
  location: variable log of type sun.rmi.runtime.Log</p>

<pre><code>            }
        }
        catch(IOException x) { exc = true; throw x; }
        catch(Exception x) { exc = true; x.printStackTrace(); }
        finally
        {
            if (exc)
            {
                try
                {
                    if (fos != null) { fos.close(); fos = null; }
                    if (osw != null) { osw.close(); fos = null; }
                    if (bw != null)  { bw.close(); bw = null; }
                }
                catch(Exception x) { x.printStackTrace(); }
            }
        }
        return log;
    }


    public synchronized void nl()
    {
        try { bw.newLine(); }
        catch(IOException x) {x.printStackTrace();}
    }

    public synchronized void nl(int count)
    {
        try
        {
            for (int i = 0; i &lt; count; i++) bw.newLine();
        }
        catch(IOException x) {x.printStackTrace();}
    }
    public synchronized void writeln(String s)
    {
        try { bw.write(getTime() + ": " + s); bw.newLine(); }
        catch(IOException x) {x.printStackTrace();}
    }

    public synchronized void write(String s)
    {
        try { bw.write(s); }
        catch (IOException x) {x.printStackTrace();}
    }

    public synchronized void close()
    {
        try
        {
            if (bw != null)
            {
                writeln("logged out.");
                nl();
                bw.flush();
                bw.close();
                closed = true;

                fos = null;
                osw = null;
                bw = null;
            }
        }
        catch(IOException x) { x.printStackTrace(); }

    }

    public synchronized boolean isClosed() { return closed; }

    public synchronized void writeException(Exception x)
    {
        writeln("");
        write("\t" + x.toString()); nl();
        StackTraceElement[] ste = x.getStackTrace();
        int j = 0;
        for (int i = 0; i &lt; ste.length; i++)
        {

            if (i &lt; 15) { write("\t\tat " + ste[i].toString()); nl(); }
            else { j++; }

        }

        if (j &gt; 0) { write("\t\t... " + j + " more"); nl(); }

        nl(2);
    }

    private String getTime()
    {
        Calendar c = Calendar.getInstance();
        int month = c.get(Calendar.MONTH) + 1;

        int d = c.get(Calendar.DAY_OF_MONTH);
        int h = c.get(Calendar.HOUR_OF_DAY);

        int m = c.get(Calendar.MINUTE);
        int s = c.get(Calendar.SECOND);
        int y = c.get(Calendar.YEAR);

        String dd = d &lt; 10 ? "0"+d : ""+d;
        String hh = h &lt; 10 ? "0"+h : ""+h;
        String mm = m &lt; 10 ? "0"+m : ""+m;
        String ss = s &lt; 10 ? "0"+s : ""+s;
        String sm = month &lt; 10 ? "0"+month : ""+month;

        return user + " [" + y + "." + sm + "." + dd + " " + hh +  ":" + mm +  ":" + ss + "]";
    }





}
</code></pre>
