Ana içeriğe geç

Logback Connection

General Information​

Connection Type​

logback

UI Documentation​

Endpoints​

List Connections​

GET /apiops/projects/{projectName}/connections/?type=logback

Get Connection​

GET /apiops/projects/{projectName}/connections/{connectionName}/

Create Connection​

POST /apiops/projects/{projectName}/connections/{connectionName}/

Update Connection​

PUT /apiops/projects/{projectName}/connections/{connectionName}/

Delete Connection​

DELETE /apiops/projects/{projectName}/connections/{connectionName}/

List Connections​

Endpoint​

GET /apiops/projects/{projectName}/connections/?type=logback

Request​

Headers​

HeaderValue
AuthorizationBearer {token}

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name

Note: The type query parameter is required to filter connections by type.

cURL Example​

curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/connections/" \
-H "Authorization: Bearer YOUR_TOKEN"

Get Connection​

Endpoint​

GET /apiops/projects/{projectName}/connections/{connectionName}/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
connectionNamestringYesConnection name

Response​

Success Response (200 OK)​

{
"success": true,
"resultList": [
{
"type": "logback",
"name": "my-logback-connection",
"description": "Logback connection for file logging",
"enabled": true,
"logPath": "/var/log/apinizer/",
"logFileName": "ApinizerApiProxyTraffic",
"logPodName": "worker-1",
"logFilenamePattern": "%d{yyyy-MM-dd}.%i.log",
"logPattern": "%d{yyyy-MM-dd HH:mm:ss.SSS}[%m]%n",
"maxFileSize": 25,
"maxHistory": 30,
"totalSizeCap": 10
}
],
"resultCount": 1
}

cURL Example​

curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/connections/my-logback-connection/" \
-H "Authorization: Bearer YOUR_TOKEN"

Create Connection​

Endpoint​

POST /apiops/projects/{projectName}/connections/{connectionName}/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
connectionNamestringYesConnection name

Request Body​

Full JSON Body Example - Basic Logback Connection​
{
"type": "logback",
"name": "my-logback-connection",
"description": "Logback connection for file logging",
"enabled": true,
"logPath": "/var/log/apinizer/",
"logFileName": "ApinizerApiProxyTraffic",
"logPodName": "",
"logFilenamePattern": "%d{yyyy-MM-dd}.%i.log",
"logPattern": "%d{yyyy-MM-dd HH:mm:ss.SSS}[%m]%n",
"maxFileSize": 25,
"maxHistory": 30,
"totalSizeCap": 10
}
Full JSON Body Example - Custom Pattern​
{
"type": "logback",
"name": "my-custom-logback",
"description": "Logback with custom pattern",
"enabled": true,
"logPath": "/opt/logs/",
"logFileName": "ApiTraffic",
"logPodName": "pod-1",
"logFilenamePattern": "%d{yyyy-MM-dd-HH}.%i.log",
"logPattern": "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %level %logger{36} - %msg%n",
"maxFileSize": 50,
"maxHistory": 7,
"totalSizeCap": 5
}
Full JSON Body Example - Unbounded Retention​
{
"type": "logback",
"name": "my-unbounded-logback",
"description": "Logback with unbounded retention",
"enabled": true,
"logPath": "/var/log/apinizer/",
"logFileName": "ApinizerApiProxyTraffic",
"logPodName": "",
"logFilenamePattern": "%d{yyyy-MM-dd}.%i.log",
"logPattern": "%d{yyyy-MM-dd HH:mm:ss.SSS}[%m]%n",
"maxFileSize": 25,
"maxHistory": 0,
"totalSizeCap": 0
}
Request Body Fields​
Common Fields​
FieldTypeRequiredDefaultDescription
typestringYes-Connection type discriminator field. Identifies the connection type in API requests/responses.
namestringYes-Connection name (must match path parameter)
descriptionstringNo-Connection description
enabledbooleanNotrueWhether connection is enabled
Logback-Specific Fields​
FieldTypeRequiredDefaultDescription
logPathstringYes/path/to/logs/Directory path where log files will be written (must end with /)
logFileNamestringYesApinizerApiProxyTrafficBase name for log files
logPodNamestringYes""Pod/host identifier (auto-filled with hostname if empty)
logFilenamePatternstringYes%d{yyyy-MM-dd}.%i.logPattern for rolled log file names (date and index pattern)
logPatternstringYes%d{yyyy-MM-dd HH:mm:ss.SSS}[%m]%nLog message format pattern
maxFileSizeintegerYes25Maximum size of a single log file in MB (before rolling)
maxHistoryintegerYes0Maximum number of days/hours to keep rolled log files (0 = unbounded)
totalSizeCapintegerYes0Maximum total size of all log files in GB (0 = unbounded)

Log Pattern Format​

  • %d{pattern} - Date/time with pattern (e.g., yyyy-MM-dd HH:mm:ss.SSS)
  • %m - Message content
  • %n - Newline
  • %thread - Thread name
  • %level - Log level
  • %logger{length} - Logger name (with optional length)
  • %msg - Message
  • See Logback PatternLayout documentation for full pattern syntax

Filename Pattern Format​

  • %d{pattern} - Date pattern for rolled files (e.g., yyyy-MM-dd)
  • %i - Index number for files rolled on the same day
  • Example: %d{yyyy-MM-dd}.%i.log creates files like 2024-01-15.0.log, 2024-01-15.1.log

Notes​

  • logPath is required and should end with / (automatically added if missing).
  • logFileName is required and should not start with / (automatically removed if present).
  • logPodName is auto-filled with hostname if empty or not provided.
  • logFilenamePattern uses Logback date pattern syntax.
  • logPattern uses Logback PatternLayout syntax.
  • maxFileSize is in MB (default: 25 MB).
  • maxHistory is in days/hours (0 = unbounded, keep all files).
  • totalSizeCap is in GB (0 = unbounded, no size limit).
  • File rolling occurs when maxFileSize is reached or time-based pattern triggers.
  • Final log file name format: {logPath}{logFileName}-{logPodName}-{logFilenamePattern}

Response​

Success Response (200 OK)​

{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}

cURL Example​

curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/connections/my-logback-connection/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "logback",
"name": "my-logback-connection",
"description": "Logback connection for file logging",
"enabled": true,
"logPath": "/var/log/apinizer/",
"logFileName": "ApinizerApiProxyTraffic",
"logPodName": "",
"logFilenamePattern": "%d{yyyy-MM-dd}.%i.log",
"logPattern": "%d{yyyy-MM-dd HH:mm:ss.SSS}[%m]%n",
"maxFileSize": 25,
"maxHistory": 30,
"totalSizeCap": 10
}'

Update Connection​

Endpoint​

PUT /apiops/projects/{projectName}/connections/{connectionName}/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
connectionNamestringYesConnection name (must match name in body)

Request Body​

Full JSON Body Example​
{
"type": "logback",
"name": "my-logback-connection",
"description": "Updated Logback connection for file logging",
"enabled": true,
"logPath": "/var/log/apinizer/prod/",
"logFileName": "ApinizerApiProxyTrafficProd",
"logPodName": "worker-1",
"logFilenamePattern": "%d{yyyy-MM-dd-HH}.%i.log",
"logPattern": "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n",
"maxFileSize": 50,
"maxHistory": 90,
"totalSizeCap": 20
}

Note: Request body structure is the same as Create Connection. All fields should be provided for update.

Response​

Success Response (200 OK)​

{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": [...]
}
}

Delete Connection​

Endpoint​

DELETE /apiops/projects/{projectName}/connections/{connectionName}/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
connectionNamestringYesConnection name

Response​

Success Response (200 OK)​

{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": [...]
}
}

Notes and Warnings​

  • Log Path:

    • logPath must be a valid directory path
    • Path should end with / (automatically added if missing)
    • Ensure the directory exists and is writable by the application
    • Use absolute paths for clarity
  • File Naming:

    • Final log file name: {logPath}{logFileName}-{logPodName}-{logFilenamePattern}
    • Example: /var/log/apinizer/ApinizerApiProxyTraffic-worker-1-2024-01-15.0.log
    • logPodName is auto-filled with hostname if empty
  • File Rolling:

    • Files roll when maxFileSize is reached or time-based pattern triggers
    • Rolled files use index numbers (.0.log, .1.log, etc.)
    • Date pattern in logFilenamePattern determines time-based rolling
  • Retention Policy:

    • maxHistory - Maximum number of days/hours to keep rolled files (0 = unbounded)
    • totalSizeCap - Maximum total size of all log files in GB (0 = unbounded)
    • Set both to 0 for unbounded retention (not recommended for production)
  • File Size:

    • maxFileSize is in MB (default: 25 MB)
    • Larger files reduce number of files but increase processing time
    • Smaller files create more files but are easier to manage
  • Log Pattern:

    • Uses Logback PatternLayout syntax
    • Common patterns: %d{yyyy-MM-dd HH:mm:ss.SSS}[%m]%n (date + message)
    • See Logback documentation for full pattern syntax
  • Performance:

    • File I/O can impact performance
    • Use appropriate maxFileSize to balance performance and file management
    • Consider disk I/O capacity when setting retention policies
  • Disk Space:

    • Monitor disk space usage
    • Set totalSizeCap to prevent disk space exhaustion
    • Use maxHistory to automatically clean up old files
  • Permissions:

    • Ensure application has write permissions to logPath
    • Directory must exist before logging starts
    • Consider using dedicated log directories
  • Deployment: Saving the connection deploys it to the workers; the response carries the deployment result.