# Class LoggerAppenderFile

LoggerAppenderFile appends log events to a file.

This appender uses a layout.

# Configurable parameters:

- file - Path to the target file. Relative paths are resolved based on the working directory.
- append - If set to true, the appender will append to the file, otherwise the file contents will be overwritten.

  LoggerConfigurable
  LoggerAppender
  LoggerAppenderFile

#### Direct known subclasses

LoggerAppenderDailyFile, LoggerAppenderRollingFile
Package: log4php\appenders
License: Apache License, Version 2.0
Version: $Revision: 1382274 $
Link: Appender documentation
Located at appenders/LoggerAppenderFile.php

Methods summary
`protected` | # `getTargetFile( )` Helper function which can be easily overriden by daily file appender. Helper function which can be easily overriden by daily file appender.
`protected boolean` | # `openFile( )` Acquires the target file resource, creates the destination folder if necessary. Writes layout header to file. Acquires the target file resource, creates the destination folder if necessary. Writes layout header to file.

#### Returns

`boolean`
FALSE if opening failed
`protected` | # `write( string $string )` Writes a string to the target file. Opens file if not already open. Writes a string to the target file. Opens file if not already open.

#### Parameters

$string
  `string`
  $string Data to write.

`protected` | # `writeWithLocking( mixed $string )`
`protected` | # `writeWithoutLocking( mixed $string )`
`public` | # `activateOptions( )` Prepares the appender for logging. Prepares the appender for logging. Derived appenders should override this method if option structure requires it.

#### Overrides

`LoggerAppender::activateOptions()`
`public` | # `close( )` Releases any resources allocated by the appender. Releases any resources allocated by the appender. Derived appenders should override this method to perform proper closing procedures.

#### Overrides

`LoggerAppender::close()`
`public` | # `append( `LoggerLoggingEvent` $event )` Forwards the logging event to the destination. Forwards the logging event to the destination. Derived appenders should implement this method to perform actual logging.

#### Parameters

$event
  ``LoggerLoggingEvent``
  $event

`public` | # `setFile( string $file )` Sets the 'file' parameter. Sets the 'file' parameter.

#### Parameters

$file
  `string`
  $file

`public string` | # `getFile( )` Returns the 'file' parameter. Returns the 'file' parameter.

#### Returns

`string`
`public boolean` | # `getAppend( )` Returns the 'append' parameter. Returns the 'append' parameter.

#### Returns

`boolean`
`public` | # `setAppend( boolean $append )` Sets the 'append' parameter. Sets the 'append' parameter.

#### Parameters

$append
  `boolean`
  $append

Methods inherited from LoggerAppender
`__construct(), __destruct(), addFilter(), clearFilters(), doAppend(), getDefaultLayout(), getFilter(), getFirstFilter(), getLayout(), getName(), getThreshold(), isAsSevereAsThreshold(), requiresLayout(), setLayout(), setName(), setThreshold(), warn()`

Methods inherited from LoggerConfigurable
`setBoolean(), setFileSize(), setInteger(), setLevel(), setNumeric(), setPositiveInteger(), setString()`

Properties summary
`protected boolean` | $locking | `true` | # If set to true, the file is locked before appending. This allows concurrent access. However, appending without locking is faster so it should be used where appropriate. If set to true, the file is locked before appending. This allows concurrent access. However, appending without locking is faster so it should be used where appropriate.

TODO: make this a configurable parameter

`protected boolean` | $append | `true` | # If set to true, appends to file. Otherwise overwrites it. If set to true, appends to file. Otherwise overwrites it.
`protected string` | $file | `` | # Path to the target file. Path to the target file.
`protected resource` | $fp | `` | # The file resource. The file resource.

Properties inherited from LoggerAppender
`$closed, $filter, $layout, $name, $requiresLayout, $threshold`